mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-05 00:36:57 +00:00
COMMON: Better handling for malformed NE Windows executables
This commit is contained in:
parent
3c4e528fff
commit
59ca2de0f2
@ -185,8 +185,15 @@ bool NEResources::readResourceTable(uint32 offset) {
|
||||
|
||||
uint16 resCount = _exe->readUint16LE();
|
||||
|
||||
debug(2, "%d resources in table", resCount);
|
||||
|
||||
_exe->skip(4); // reserved
|
||||
|
||||
if (resCount > 256) {
|
||||
warning("NEResources::readResourceTable(): resource table looks malformed, %d entries > 256", resCount);
|
||||
resCount = 256;
|
||||
}
|
||||
|
||||
for (int i = 0; i < resCount; i++) {
|
||||
Resource res;
|
||||
|
||||
@ -233,8 +240,16 @@ String NEResources::getResourceString(SeekableReadStream &exe, uint32 offset) {
|
||||
uint8 length = exe.readByte();
|
||||
|
||||
String string;
|
||||
for (uint16 i = 0; i < length; i++)
|
||||
string += (char)exe.readByte();
|
||||
for (uint16 i = 0; i < length; i++) {
|
||||
char b = (char)exe.readByte();
|
||||
|
||||
// Do not read beyond end of string
|
||||
if (!b) {
|
||||
break;
|
||||
}
|
||||
|
||||
string += b;
|
||||
}
|
||||
|
||||
exe.seek(curPos);
|
||||
return string;
|
||||
|
Loading…
Reference in New Issue
Block a user