mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 02:52:53 +02:00
[Object/ELF] - Check Header->e_shoff value earlier and do not crash.
Patch checks that section pointer is aligned properly. This should be done before getStringTable() call. Differential revision: https://reviews.llvm.org/D25462 llvm-svn: 284387
This commit is contained in:
parent
d49808acaf
commit
cd256ad4ac
@ -334,6 +334,12 @@ ELFFile<ELFT>::ELFFile(StringRef Object, std::error_code &EC)
|
||||
return;
|
||||
}
|
||||
|
||||
if (SectionTableOffset & (AlignOf<Elf_Shdr>::Alignment - 1)) {
|
||||
// Invalid address alignment of section headers
|
||||
EC = object_error::parse_failed;
|
||||
return;
|
||||
}
|
||||
|
||||
// The getNumSections() call below depends on SectionHeaderTable being set.
|
||||
SectionHeaderTable =
|
||||
reinterpret_cast<const Elf_Shdr *>(base() + SectionTableOffset);
|
||||
|
BIN
test/Object/Inputs/invalid-sections-address-alignment.x86-64
Normal file
BIN
test/Object/Inputs/invalid-sections-address-alignment.x86-64
Normal file
Binary file not shown.
@ -67,3 +67,7 @@ RUN: FileCheck --check-prefix=INVALID-RELOC-SH-OFFSET %s
|
||||
RUN: not llvm-readobj -r %p/Inputs/invalid-relocation-sec-sh_offset.elf-x86-64 2>&1 | \
|
||||
RUN: FileCheck --check-prefix=INVALID-RELOC-SH-OFFSET %s
|
||||
INVALID-RELOC-SH-OFFSET: Invalid data was encountered while parsing the file
|
||||
|
||||
RUN: not llvm-readobj -t %p/Inputs/invalid-sections-address-alignment.x86-64 2>&1 | \
|
||||
RUN: FileCheck --check-prefix=INVALID-SEC-ADDRESS-ALIGNMENT %s
|
||||
INVALID-SEC-ADDRESS-ALIGNMENT: Invalid data was encountered while parsing the file
|
||||
|
Loading…
Reference in New Issue
Block a user