[Scummvm-cvs-logs] scummvm master -> 16152cf1ea7807546cc40c8ba094ce874e2f877a

digitall dgturner at iee.org
Sat May 17 13:13:21 CEST 2014


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:
71aab5ab1d HOPKINS: Add null termination to byte buffer returned by loadFile().
16152cf1ea HOPKINS: Add sanity check to parsing of COMPUTAN.TXT file.


Commit: 71aab5ab1df735bdcd776b05a5a180a3482a1345
    https://github.com/scummvm/scummvm/commit/71aab5ab1df735bdcd776b05a5a180a3482a1345
Author: D G Turner (digitall at scummvm.org)
Date: 2014-05-17T12:12:19+01:00

Commit Message:
HOPKINS: Add null termination to byte buffer returned by loadFile().

This shouldn't be a problem, as current client code either must find a
terminator when parsing the byte buffer or have preknowledge of the
buffer size from a file size or fixed call, so the appended null
termination will not cause issues. This change thus allows client code
to add sanity checks to prevent reading off the end of the buffer.

Changed paths:
    engines/hopkins/files.cpp



diff --git a/engines/hopkins/files.cpp b/engines/hopkins/files.cpp
index 75f429f..6620f28 100644
--- a/engines/hopkins/files.cpp
+++ b/engines/hopkins/files.cpp
@@ -51,12 +51,13 @@ byte *FileManager::loadFile(const Common::String &file) {
 
 	// Allocate space for the file contents
 	size_t filesize = f.size();
-	byte *data = _vm->_globals->allocMemory(filesize);
+	byte *data = _vm->_globals->allocMemory(filesize+1);
 	if (!data)
 		error("Error allocating space for file being loaded - %s", file.c_str());
 
 	readStream(f, data, filesize);
 	f.close();
+	data[filesize] = '\0';
 
 	return data;
 }


Commit: 16152cf1ea7807546cc40c8ba094ce874e2f877a
    https://github.com/scummvm/scummvm/commit/16152cf1ea7807546cc40c8ba094ce874e2f877a
Author: D G Turner (digitall at scummvm.org)
Date: 2014-05-17T12:16:19+01:00

Commit Message:
HOPKINS: Add sanity check to parsing of COMPUTAN.TXT file.

This previously crashed on the Polish version due to a variant file
format causing the parsing to make several invalid memory accesses.

This prevents this crash and any other in future, though it does not
fix the parsing of the variant file format.

Changed paths:
    engines/hopkins/computer.cpp



diff --git a/engines/hopkins/computer.cpp b/engines/hopkins/computer.cpp
index 1307cd5..4f8e373 100644
--- a/engines/hopkins/computer.cpp
+++ b/engines/hopkins/computer.cpp
@@ -392,7 +392,7 @@ void ComputerManager::loadMenu() {
 			++lineNum;
 		}
 		++tmpPtr;
-	} while (!loopCond);
+	} while (!loopCond && tmpPtr[0] != '\0' && lineNum < 50);
 	_vm->_globals->freeMemory((byte *)ptr);
 }
 






More information about the Scummvm-git-logs mailing list