[PATCH] D25189: [Object/ELF] - Avoid possible crash in getExtendedSymbolTableIndex().
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 4 01:53:06 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283196: [Object/ELF] - Avoid possible crash in getExtendedSymbolTableIndex(). (authored by grimar).
Changed prior to commit:
https://reviews.llvm.org/D25189?vs=73280&id=73427#toc
Repository:
rL LLVM
https://reviews.llvm.org/D25189
Files:
llvm/trunk/include/llvm/Object/ELF.h
llvm/trunk/test/Object/Inputs/invalid-ext-symtab-index.elf-x86-64
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
@@ -225,7 +225,8 @@
ArrayRef<Elf_Word> ShndxTable) const {
assert(Sym->st_shndx == ELF::SHN_XINDEX);
unsigned Index = Sym - FirstSym;
-
+ if (Index >= ShndxTable.size())
+ report_fatal_error("Invalid symbol table index");
// The size of the table was checked in getSHNDXTable.
return ShndxTable[Index];
}
Index: llvm/trunk/test/Object/invalid.test
===================================================================
--- llvm/trunk/test/Object/invalid.test
+++ llvm/trunk/test/Object/invalid.test
@@ -54,3 +54,7 @@
RUN: not llvm-readobj -t %p/Inputs/invalid-xindex-size.elf 2>&1 | FileCheck --check-prefix=INVALID-XINDEX-SIZE %s
INVALID-XINDEX-SIZE: Invalid data was encountered while parsing the file.
+
+RUN: not llvm-readobj -t %p/Inputs/invalid-ext-symtab-index.elf-x86-64 2>&1 | \
+RUN: FileCheck --check-prefix=INVALID-EXT-SYMTAB-INDEX %s
+INVALID-EXT-SYMTAB-INDEX: Invalid symbol table index
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25189.73427.patch
Type: text/x-patch
Size: 1120 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161004/3f90d335/attachment.bin>
More information about the llvm-commits
mailing list