[PATCH] D25327: [ELF] - Do not crash on invalid size of dynamic section.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 7 02:10:11 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283533: [ELF] - Do not crash on invalid size of dynamic section. (authored by grimar).
Changed prior to commit:
https://reviews.llvm.org/D25327?vs=73797&id=73895#toc
Repository:
rL LLVM
https://reviews.llvm.org/D25327
Files:
lld/trunk/ELF/InputFiles.cpp
lld/trunk/test/ELF/invalid/Inputs/dynamic-section-sh_size.elf
lld/trunk/test/ELF/invalid/dynamic-section-size.s
Index: lld/trunk/test/ELF/invalid/dynamic-section-size.s
===================================================================
--- lld/trunk/test/ELF/invalid/dynamic-section-size.s
+++ lld/trunk/test/ELF/invalid/dynamic-section-size.s
@@ -0,0 +1,4 @@
+## dynamic-section-sh_size.elf has incorrect sh_size of dynamic section.
+# RUN: not ld.lld %p/Inputs/dynamic-section-sh_size.elf -o %t2 2>&1 | \
+# RUN: FileCheck %s
+# CHECK: getSectionContentsAsArray failed: Invalid data was encountered while parsing the file
Index: lld/trunk/ELF/InputFiles.cpp
===================================================================
--- lld/trunk/ELF/InputFiles.cpp
+++ lld/trunk/ELF/InputFiles.cpp
@@ -523,11 +523,11 @@
if (!DynamicSec)
return;
- auto *Begin =
- reinterpret_cast<const Elf_Dyn *>(Obj.base() + DynamicSec->sh_offset);
- const Elf_Dyn *End = Begin + DynamicSec->sh_size / sizeof(Elf_Dyn);
- for (const Elf_Dyn &Dyn : make_range(Begin, End)) {
+ ArrayRef<Elf_Dyn> Arr =
+ check(Obj.template getSectionContentsAsArray<Elf_Dyn>(DynamicSec),
+ getFilename(this) + ": getSectionContentsAsArray failed");
+ for (const Elf_Dyn &Dyn : Arr) {
if (Dyn.d_tag == DT_SONAME) {
uintX_t Val = Dyn.getVal();
if (Val >= this->StringTable.size())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25327.73895.patch
Type: text/x-patch
Size: 1288 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161007/2f5e3ac4/attachment.bin>
More information about the llvm-commits
mailing list