[PATCH] D25091: [Object/ELF] - Do not crash if string table sh_size is equal to zero.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 27 04:51:33 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285282: [Object/ELF] - Do not crash if string table sh_size is equal to zero. (authored by grimar).
Changed prior to commit:
https://reviews.llvm.org/D25091?vs=74118&id=76007#toc
Repository:
rL LLVM
https://reviews.llvm.org/D25091
Files:
llvm/trunk/include/llvm/Object/ELF.h
llvm/trunk/test/Object/Inputs/invalid-strtab-zero-size.elf
llvm/trunk/test/Object/invalid.test
Index: llvm/trunk/include/llvm/Object/ELF.h
===================================================================
--- llvm/trunk/include/llvm/Object/ELF.h
+++ llvm/trunk/include/llvm/Object/ELF.h
@@ -428,6 +428,8 @@
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());
Index: llvm/trunk/test/Object/invalid.test
===================================================================
--- llvm/trunk/test/Object/invalid.test
+++ llvm/trunk/test/Object/invalid.test
@@ -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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25091.76007.patch
Type: text/x-patch
Size: 1193 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161027/5a986bc6/attachment.bin>
More information about the llvm-commits
mailing list