GT-3241: Better handling of stripped ELF section headers (fixes #1119).

This commit is contained in:
Ryan Kurtz
2019-10-17 10:20:47 -04:00
parent ed098ca34f
commit e6358b5939
@@ -159,8 +159,14 @@ public class ElfHeader implements StructConverter, Writeable {
e_ehsize = reader.readNextShort();
e_phentsize = reader.readNextShort();
e_phnum = reader.readNextShort();
if (e_phnum < 0) {
e_phnum = 0; // protect against stripped program headers
}
e_shentsize = reader.readNextShort();
e_shnum = reader.readNextShort();
if (e_shnum < 0) {
e_shnum = 0; // protect against stripped section headers (have seen -1)
}
e_shstrndx = reader.readNextShort();
}
catch (IOException e) {