[Scummvm-git-logs] scummvm master -> 7d4d135b99d7454b2f4d3a8c25e0ed47828a759f

sev- noreply at scummvm.org
Mon Aug 8 00:06:56 UTC 2022


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:
74c253bef8 COMMON: Some programs store AppleDouble files in *.rsrc. Check for that
7d4d135b99 COMMON: Add sanity checks to MacResManager::readMap()


Commit: 74c253bef8c15bd7d41e1f6dedb840be888250d0
    https://github.com/scummvm/scummvm/commit/74c253bef8c15bd7d41e1f6dedb840be888250d0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2022-08-08T02:05:06+02:00

Commit Message:
COMMON: Some programs store AppleDouble files in *.rsrc. Check for that

Changed paths:
    common/macresman.cpp


diff --git a/common/macresman.cpp b/common/macresman.cpp
index 3b8787ac770..09fbba2a963 100644
--- a/common/macresman.cpp
+++ b/common/macresman.cpp
@@ -154,9 +154,21 @@ bool MacResManager::open(const Path &fileName, Archive &archive) {
 
 	// Prefer standalone files first, starting with raw forks
 	SeekableReadStream *stream = archive.createReadStreamForMember(fileName.append(".rsrc"));
-	if (stream && loadFromRawFork(*stream)) {
-		_baseFileName = fileName;
-		return true;
+
+	if (stream) {
+		// Some programs actually store AppleDouble there. Check it
+		bool appleDouble = (stream->readUint32BE() == 0x00051607);
+		stream->seek(0);
+
+		if (appleDouble && loadFromAppleDouble(*stream)) {
+			_baseFileName = fileName;
+			return true;
+		}
+
+		if (loadFromRawFork(*stream)) {
+			_baseFileName = fileName;
+			return true;
+		}
 	}
 	delete stream;
 


Commit: 7d4d135b99d7454b2f4d3a8c25e0ed47828a759f
    https://github.com/scummvm/scummvm/commit/7d4d135b99d7454b2f4d3a8c25e0ed47828a759f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2022-08-08T02:06:08+02:00

Commit Message:
COMMON: Add sanity checks to MacResManager::readMap()

Changed paths:
    common/macresman.cpp


diff --git a/common/macresman.cpp b/common/macresman.cpp
index 09fbba2a963..425c77b3d8d 100644
--- a/common/macresman.cpp
+++ b/common/macresman.cpp
@@ -598,15 +598,27 @@ void MacResManager::readMap() {
 	_stream->seek(_mapOffset + _resMap.typeOffset + 2);
 	_resTypes = new ResType[_resMap.numTypes];
 
+	debug(8, "numResTypes: %d total size: %lu", _resMap.numTypes, _stream->size());
+
+	if (_stream->pos() + _resMap.numTypes * 8 > _stream->size())
+		error("MacResManager::readMap(): incorrect resource map, too big, %d types", _resMap.numTypes);
+
+	int totalItems = 0;
+
 	for (int i = 0; i < _resMap.numTypes; i++) {
 		_resTypes[i].id = _stream->readUint32BE();
 		_resTypes[i].items = _stream->readUint16BE();
 		_resTypes[i].offset = _stream->readUint16BE();
 		_resTypes[i].items++;
 
+		totalItems += _resTypes[i].items;
+
 		debug(8, "resType: <%s> items: %d offset: %d (0x%x)", tag2str(_resTypes[i].id), _resTypes[i].items,  _resTypes[i].offset, _resTypes[i].offset);
 	}
 
+	if (totalItems * 4 > _stream->size())
+		error("MacResManager::readMap(): incorrect resource map, too big, %d total items", totalItems);
+
 	_resLists = new ResPtr[_resMap.numTypes];
 
 	for (int i = 0; i < _resMap.numTypes; i++) {




More information about the Scummvm-git-logs mailing list