GP-5199: per review

GP-5199: forgot a bit
GP-5199: fix for 0 length
This commit is contained in:
d-millar 2024-12-17 11:25:55 -05:00
parent 420dd7ce0c
commit c2224aa538

View file

@ -83,8 +83,18 @@ public class DebugMisc implements StructConverter {
actualData =
(unicode ? reader.readNextUnicodeString(length) : reader.readNextAsciiString());
}
else if (length == 0 && !unicode) {
actualData = reader.readNextAsciiString();
// NB: should be a multiple of 4 per winnt.h
// 13 = len(start of struct) + null
length = (int) Math.ceil((actualData.length() + 13)/4.0)*4;
if (length > DebugDirectory.IMAGE_SIZEOF_DEBUG_DIRECTORY) {
length = DebugDirectory.IMAGE_SIZEOF_DEBUG_DIRECTORY;
}
Msg.warn(this, "Zero length structure - defaulting to " + Integer.toHexString(length));
}
else {
Msg.error(this, "Bad string length " + Integer.toHexString(length));
Msg.error(this, "Bad structure length " + Integer.toHexString(length));
}
reader.setPointerIndex(oldIndex);