[Scummvm-git-logs] scummvm master -> 8573bd38ea980be5f5bfc807b439e5b66e117c43

phcoder noreply at scummvm.org
Sat Jan 7 16:44:40 UTC 2023


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
187304f730 COMMON: Reject all-zero macbinary header
8573bd38ea SAGA: Allow streams to be automatically reopened.


Commit: 187304f7308fa46478eb40ec6d2f4b9163b4dd40
    https://github.com/scummvm/scummvm/commit/187304f7308fa46478eb40ec6d2f4b9163b4dd40
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2023-01-07T19:44:37+03:00

Commit Message:
COMMON: Reject all-zero macbinary header

Changed paths:
    common/macresman.cpp


diff --git a/common/macresman.cpp b/common/macresman.cpp
index cf7d401fef3..bc4fab7c2d7 100644
--- a/common/macresman.cpp
+++ b/common/macresman.cpp
@@ -600,6 +600,17 @@ bool MacResManager::readAndValidateMacBinaryHeader(SeekableReadStream &stream, b
 	if (stream.read(infoHeader, MBI_INFOHDR) != MBI_INFOHDR)
 		return false;
 
+	/* CRC_BINHEX of block of zeros is zero so checksum below will lead a false positive.
+	   Header of all zeros is not a valid MacBinary header
+	   as it lacks name, resource fork and data fork.
+	   Exclude headers that have zero name len, zero data fork, zero name fork and zero type_creator.
+	   Keep it at the top as a quick and cheap check
+	*/
+	if (infoHeader[MBI_NAMELEN] == 0 && READ_BE_UINT32(infoHeader + MBI_DFLEN) == 0
+	    && READ_BE_UINT32(infoHeader + MBI_RFLEN) == 0 &&
+	    READ_BE_UINT32(infoHeader + MBI_TYPE) == 0 && READ_BE_UINT32(infoHeader + MBI_CREATOR) == 0)
+		return false;
+
 	CRC_BINHEX crc;
 	uint16 checkSum = crc.crcFast(infoHeader, 124);
 


Commit: 8573bd38ea980be5f5bfc807b439e5b66e117c43
    https://github.com/scummvm/scummvm/commit/8573bd38ea980be5f5bfc807b439e5b66e117c43
Author: Vladimir Serbinenko (phcoder at gmail.com)
Date: 2023-01-07T19:44:37+03:00

Commit Message:
SAGA: Allow streams to be automatically reopened.

This is needed for IHNM chapter switch and was lost in switch to
common macbinary

Changed paths:
    engines/saga/resource.h


diff --git a/engines/saga/resource.h b/engines/saga/resource.h
index 2e65dcd602a..1fdeaeaf071 100644
--- a/engines/saga/resource.h
+++ b/engines/saga/resource.h
@@ -109,7 +109,7 @@ public:
 	ResourceContext():
 		_fileName(NULL), _fileType(0), _isCompressed(false), _serial(0),
 		_isBigEndian(false),
-		_fileSize(0) {
+		_fileSize(0), _tombstone(false) {
 	}
 
 	virtual ~ResourceContext() { }
@@ -125,6 +125,11 @@ public:
 		if (resourceData && resourceData->patchData != NULL) {
 			return resourceData->patchData->getStream();
 		} else {
+			if (!_file && !_tombstone)
+				_file.reset(Common::MacResManager::openFileOrDataFork(_fileName));
+			if (!_file)
+				_tombstone = true;
+
 			return _file.get();
 		}
 	}
@@ -155,6 +160,7 @@ protected:
 	Common::ScopedPtr<Common::SeekableReadStream> _file;
 	Common::ScopedPtr<Common::MacResManager> _macRes;
 	int32 _fileSize;
+	bool _tombstone;
 
 	bool load(SagaEngine *_vm, Resource *resource);
 	bool loadResV1();




More information about the Scummvm-git-logs mailing list