COMMON: Proper check for MacBinary presence. This fixes false positives for QT movies

This commit is contained in:
Eugene Sandulenko 2021-08-10 19:32:48 +02:00
parent d44938f916
commit b72d6d89b9
No known key found for this signature in database
GPG Key ID: 014D387312D34F08

View File

@ -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) {