[PATCH] [Request, 3 lines] 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
Fri Sep 30 04:58:01 PDT 2016
grimar created this revision.
grimar added reviewers: rafael, davide.
grimar added subscribers: llvm-commits, grimar, evgeny777.
Revealed using "id_000038,sig_11,src_000015,op_havoc,rep_16" from PR30540,
when sh_size was 0, crash happened.
https://reviews.llvm.org/D25091
Files:
include/llvm/Object/ELF.h
test/Object/Inputs/invalid-strtab-zero-size.elf
test/Object/invalid.test
Index: test/Object/invalid.test
===================================================================
--- test/Object/invalid.test
+++ 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
Index: include/llvm/Object/ELF.h
===================================================================
--- include/llvm/Object/ELF.h
+++ include/llvm/Object/ELF.h
@@ -437,7 +437,7 @@
return object_error::parse_failed;
uint64_t Offset = Section->sh_offset;
uint64_t Size = Section->sh_size;
- if (Offset + Size > Buf.size())
+ if (!Size || Offset + Size > Buf.size())
return object_error::parse_failed;
StringRef Data((const char *)base() + Section->sh_offset, Size);
if (Data[Size - 1] != '\0')
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25091.73038.patch
Type: text/x-patch
Size: 1201 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160930/e8b87457/attachment.bin>
More information about the llvm-commits
mailing list