[PATCH] [Request, 7 lines] D25087: [Object/ELF] - Do check for invalid section header entry size earlier.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 30 03:35:57 PDT 2016
grimar created this revision.
grimar added reviewers: rafael, davide.
grimar added subscribers: llvm-commits, grimar, evgeny777.
Zero value in e_shentsize was the reason of crash in lld.
When we have zero size and huge amount of sections,
resize() in below code could fail.
template <class ELFT>
void elf::ObjectFile<ELFT>::initializeSections(
DenseSet<StringRef> &ComdatGroups) {
uint64_t Size = this->ELFObj.getNumSections();
Sections.resize(Size);
No any new testcase as this fatal message is already has one.
https://reviews.llvm.org/D25087
Files:
ELF.h
Index: ELF.h
===================================================================
--- ELF.h
+++ ELF.h
@@ -356,6 +356,10 @@
return;
}
+ if (Header->e_shentsize != sizeof(Elf_Shdr))
+ report_fatal_error(
+ "Invalid section header entry size (e_shentsize) in ELF header");
+
// The getNumSections() call below depends on SectionHeaderTable being set.
SectionHeaderTable =
reinterpret_cast<const Elf_Shdr *>(base() + SectionTableOffset);
@@ -390,9 +394,6 @@
template <class ELFT>
const typename ELFFile<ELFT>::Elf_Shdr *ELFFile<ELFT>::section_begin() const {
- if (Header->e_shentsize != sizeof(Elf_Shdr))
- report_fatal_error(
- "Invalid section header entry size (e_shentsize) in ELF header");
return reinterpret_cast<const Elf_Shdr *>(base() + Header->e_shoff);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25087.73028.patch
Type: text/x-patch
Size: 834 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160930/ecb12801/attachment.bin>
More information about the llvm-commits
mailing list