forked from OSchip/llvm-project
[Object/ELF] - Do not crash if string table sh_size is equal to zero.
Revealed using "id_000038,sig_11,src_000015,op_havoc,rep_16" from PR30540, when sh_size was 0, crash happened. Differential revision: https://reviews.llvm.org/D25091 llvm-svn: 285282
This commit is contained in:
parent
d2611d50aa
commit
3fb09b3a9e
llvm
|
@ -428,6 +428,8 @@ ELFFile<ELFT>::getStringTable(const Elf_Shdr *Section) const {
|
|||
if (std::error_code EC = V.getError())
|
||||
return EC;
|
||||
ArrayRef<char> Data = *V;
|
||||
if (Data.empty())
|
||||
return object_error::parse_failed;
|
||||
if (Data.back() != '\0')
|
||||
return object_error::string_table_non_null_end;
|
||||
return StringRef(Data.begin(), Data.size());
|
||||
|
|
Binary file not shown.
|
@ -1,6 +1,7 @@
|
|||
RUN: not llvm-dwarfdump %p/Inputs/invalid-bad-rel-type.elf 2>&1 | FileCheck %s
|
||||
RUN: not llvm-objdump -s %p/Inputs/invalid-strtab-type.elf 2>&1 | FileCheck %s
|
||||
RUN: not llvm-objdump -s %p/Inputs/invalid-strtab-size.elf 2>&1 | FileCheck %s
|
||||
RUN: not llvm-objdump -s %p/Inputs/invalid-strtab-zero-size.elf 2>&1 | FileCheck %s
|
||||
CHECK: Invalid data was encountered while parsing the file
|
||||
|
||||
RUN: not llvm-objdump -s %p/Inputs/invalid-strtab-non-null.elf 2>&1 | FileCheck --check-prefix=NON-NULL %s
|
||||
|
|
Loading…
Reference in New Issue