diff options
author | Alyssa Milburn | 2010-12-11 19:53:44 +0000 |
---|---|---|
committer | Alyssa Milburn | 2010-12-11 19:53:44 +0000 |
commit | 7c97a86a9a7f111ccf9b5a2c9e59b4bb499006c6 (patch) | |
tree | 5710eee9704487fb9dad76dd3bd5dae26191c23a | |
parent | 60c844efd3f86e4c9131d1a2c34490b6d31cc873 (diff) | |
download | scummvm-rg350-7c97a86a9a7f111ccf9b5a2c9e59b4bb499006c6.tar.gz scummvm-rg350-7c97a86a9a7f111ccf9b5a2c9e59b4bb499006c6.tar.bz2 scummvm-rg350-7c97a86a9a7f111ccf9b5a2c9e59b4bb499006c6.zip |
MOHAWK: Add size check when reading LB messages
svn-id: r54870
-rw-r--r-- | engines/mohawk/livingbooks.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/engines/mohawk/livingbooks.cpp b/engines/mohawk/livingbooks.cpp index 2c75b8bf6e..c9397a7612 100644 --- a/engines/mohawk/livingbooks.cpp +++ b/engines/mohawk/livingbooks.cpp @@ -1625,12 +1625,18 @@ void LBItem::readFrom(Common::SeekableSubReadStreamEndian *stream) { if (stream->pos() == endPos) break; + uint oldPos = stream->pos(); + uint16 dataType = stream->readUint16(); uint16 dataSize = stream->readUint16(); debug(4, "Data type %04x, size %d", dataType, dataSize); readData(dataType, dataSize, stream); + if ((uint)stream->pos() != oldPos + 4 + (uint)dataSize) + error("Failed to read correct number of bytes (off by %d) for data type %04x (size %d)", + (int)stream->pos() - (int)(oldPos + 4 + (uint)dataSize), dataType, dataSize); + if (stream->pos() > endPos) error("Read off the end (at %d) of data (ends at %d)", stream->pos(), endPos); |