diff options
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/Object/ELF.h | 3 | ||||
| -rw-r--r-- | llvm/test/Object/Inputs/invalid-strtab-type.elf | bin | 0 -> 536 bytes | |||
| -rw-r--r-- | llvm/test/Object/invalid.test | 1 |
3 files changed, 3 insertions, 1 deletions
diff --git a/llvm/include/llvm/Object/ELF.h b/llvm/include/llvm/Object/ELF.h index ed8ce5aea74..662057a40b5 100644 --- a/llvm/include/llvm/Object/ELF.h +++ b/llvm/include/llvm/Object/ELF.h @@ -867,7 +867,8 @@ ELFFile<ELFT>::getSection(uint32_t index) const { template <class ELFT> ErrorOr<StringRef> ELFFile<ELFT>::getString(const Elf_Shdr *Section, ELF::Elf32_Word Offset) const { - assert(Section && Section->sh_type == ELF::SHT_STRTAB && "Invalid section!"); + if (Section->sh_type != ELF::SHT_STRTAB) + return object_error::parse_failed; if (Offset >= Section->sh_size) return object_error::parse_failed; return StringRef((const char *)base() + Section->sh_offset + Offset); diff --git a/llvm/test/Object/Inputs/invalid-strtab-type.elf b/llvm/test/Object/Inputs/invalid-strtab-type.elf Binary files differnew file mode 100644 index 00000000000..2a072ebe51d --- /dev/null +++ b/llvm/test/Object/Inputs/invalid-strtab-type.elf diff --git a/llvm/test/Object/invalid.test b/llvm/test/Object/invalid.test index 73bf62a1ed4..2e2c924dfae 100644 --- a/llvm/test/Object/invalid.test +++ b/llvm/test/Object/invalid.test @@ -1,2 +1,3 @@ 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 CHECK: Invalid data was encountered while parsing the file |

