mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-19 08:25:35 +00:00
COMMON: Proper check for MacBinary presence. This fixes false positives for QT movies
This commit is contained in:
parent
d44938f916
commit
b72d6d89b9
@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "common/crc.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/util.h"
|
||||
#include "common/file.h"
|
||||
@ -308,6 +309,14 @@ bool MacResManager::isMacBinary(SeekableReadStream &stream) {
|
||||
if (stream.read(infoHeader, MBI_INFOHDR) != MBI_INFOHDR)
|
||||
return false;
|
||||
|
||||
CRC_BINHEX crc;
|
||||
crc.init();
|
||||
uint16 checkSum = crc.crcFast(infoHeader, 124);
|
||||
|
||||
// Sanity check on the CRC. Some movies could look like MacBinary
|
||||
if (checkSum != READ_BE_UINT16(&infoHeader[124]))
|
||||
return false;
|
||||
|
||||
if (infoHeader[MBI_ZERO1] == 0 && infoHeader[MBI_ZERO2] == 0 &&
|
||||
infoHeader[MBI_ZERO3] == 0 && infoHeader[MBI_NAMELEN] <= MAXNAMELEN) {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user