Gracefully handle ELF files with empty string table

This commit is contained in:
Julian Stecklina
2020-11-15 14:40:10 +01:00
parent 62e39e05dc
commit cee8c8cda7

View File

@@ -436,7 +436,9 @@ ElfFile<ElfFileParamNames>::ElfFile(FileContents fileContents)
char * shstrtab = (char * ) contents + rdi(shdrs[shstrtabIndex].sh_offset);
checkPointer(fileContents, shstrtab, shstrtabSize);
assert(shstrtabSize > 0);
if (shstrtabSize == 0)
error("string table size is zero");
assert(shstrtab[shstrtabSize - 1] == 0);
sectionNames = std::string(shstrtab, shstrtabSize);