[llvm] r226229 - Fix edge case when Start overflowed in 32 bit mode
Filipe Cabecinhas
me at filcab.net
Thu Jan 15 15:50:44 PST 2015
Author: filcab
Date: Thu Jan 15 17:50:44 2015
New Revision: 226229
URL: http://llvm.org/viewvc/llvm-project?rev=226229&view=rev
Log:
Fix edge case when Start overflowed in 32 bit mode
Modified:
llvm/trunk/lib/Object/MachOObjectFile.cpp
llvm/trunk/test/Object/macho-invalid.test
Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=226229&r1=226228&r2=226229&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Thu Jan 15 17:50:44 2015
@@ -336,8 +336,9 @@ std::error_code MachOObjectFile::getSymb
StringRef StringTable = getStringTableData();
MachO::nlist_base Entry = getSymbolTableEntryBase(this, Symb);
const char *Start = &StringTable.data()[Entry.n_strx];
- if (Start >= getData().end())
- report_fatal_error("Symbol name entry points past end of file.");
+ if (Start < getData().begin() || Start >= getData().end())
+ report_fatal_error(
+ "Symbol name entry points before beginning or past end of file.");
Res = StringRef(Start);
return object_error::success;
}
Modified: llvm/trunk/test/Object/macho-invalid.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/macho-invalid.test?rev=226229&r1=226228&r2=226229&view=diff
==============================================================================
--- llvm/trunk/test/Object/macho-invalid.test (original)
+++ llvm/trunk/test/Object/macho-invalid.test Thu Jan 15 17:50:44 2015
@@ -43,7 +43,7 @@ SMALL-SEGLOADC-SIZE: Segment load comman
INCOMPLETE-LOADC: Malformed MachO file
TOO-MANY-SECTS: Number of sections too large for size of load command
BAD-SYMBOL: Requested symbol index is out of range
-NAME-PAST-EOF: Symbol name entry points past end of file
+NAME-PAST-EOF: Symbol name entry points before beginning or past end of file
INVALID-SECTION-IDX-SEG-NAME: getSectionRawFinalSegmentName: Invalid section index
INVALID-SECTION-IDX-SECT-NAME: getSectionRawName: Invalid section index
More information about the llvm-commits
mailing list