[Scummvm-cvs-logs] scummvm master -> 662732acd7e0277b893c1f6f6fd5e0af5db0b9d4

m-kiewitz m_kiewitz at users.sourceforge.net
Tue Jun 16 00:16:15 CEST 2015


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

Summary:
662732acd7 SHERLOCK: 3DO: animation loader: verify data


Commit: 662732acd7e0277b893c1f6f6fd5e0af5db0b9d4
    https://github.com/scummvm/scummvm/commit/662732acd7e0277b893c1f6f6fd5e0af5db0b9d4
Author: Martin Kiewitz (m_kiewitz at users.sourceforge.net)
Date: 2015-06-16T00:15:15+02:00

Commit Message:
SHERLOCK: 3DO: animation loader: verify data

Changed paths:
    engines/sherlock/image_file.cpp



diff --git a/engines/sherlock/image_file.cpp b/engines/sherlock/image_file.cpp
index 5a31563..78284e4 100644
--- a/engines/sherlock/image_file.cpp
+++ b/engines/sherlock/image_file.cpp
@@ -342,13 +342,17 @@ inline uint16 ImageFile3DO::convertPixel(uint16 pixel3DO) {
 }
 
 void ImageFile3DO::loadAnimationFile(Common::SeekableReadStream &stream) {
-	int streamSize = stream.size();
-	uint32 compressedSize = 0;
+	uint32 streamLeft = stream.size() - stream.pos();
+	uint32 celDataSize = 0;
 
-	while (stream.pos() < streamSize) {
+	while (streamLeft > 0) {
 		ImageFrame frame;
 
-		compressedSize = stream.readUint16BE();
+		// We expect a basic header of 8 bytes
+		if (streamLeft < 8)
+			error("load3DOAnimationFile: expected animation header, not enough bytes");
+
+		celDataSize = stream.readUint16BE();
 
 		frame._width = stream.readUint16BE() + 1; // 2 bytes BE width
 		frame._height = stream.readByte() + 1; // 1 byte BE height
@@ -357,21 +361,27 @@ void ImageFile3DO::loadAnimationFile(Common::SeekableReadStream &stream) {
 		frame._rleEncoded = true; // always compressed
 		if (frame._width & 0x8000) {
 			frame._width &= 0x7FFF;
-			compressedSize += 0x10000;
+			celDataSize += 0x10000;
 		}
 
 		frame._offset.x = stream.readUint16BE();
 		frame._offset.y = stream.readByte();
 		frame._size = 0;
+		// Got header
+		streamLeft -= 8;
 
-		//warning("getting frame %d from offset %d", this->size(), stream.pos());
+		// cel data follows
+		if (streamLeft < celDataSize)
+			error("load3DOAnimationFile: expected cel data, not enough bytes");
 
+		// 
 		// Load data for frame and decompress it
-		byte *data = new byte[compressedSize];
-		stream.read(data, compressedSize);
+		byte *data = new byte[celDataSize];
+		stream.read(data, celDataSize);
+		streamLeft -= celDataSize;
 
 		// always 16 bits per pixel (RGB555)
-		decompress3DOCelFrame(frame, data, compressedSize, 16, NULL);
+		decompress3DOCelFrame(frame, data, celDataSize, 16, NULL);
 
 		delete[] data;
 






More information about the Scummvm-git-logs mailing list