Fix edge case when Start overflowed in 32 bit mode

llvm-svn: 226229
This commit is contained in:
Filipe Cabecinhas 2015-01-15 23:50:44 +00:00
parent 13023a1af6
commit c552c9abce
2 changed files with 4 additions and 3 deletions

View File

@ -336,8 +336,9 @@ std::error_code MachOObjectFile::getSymbolName(DataRefImpl Symb,
StringRef StringTable = getStringTableData(); StringRef StringTable = getStringTableData();
MachO::nlist_base Entry = getSymbolTableEntryBase(this, Symb); MachO::nlist_base Entry = getSymbolTableEntryBase(this, Symb);
const char *Start = &StringTable.data()[Entry.n_strx]; const char *Start = &StringTable.data()[Entry.n_strx];
if (Start >= getData().end()) if (Start < getData().begin() || Start >= getData().end())
report_fatal_error("Symbol name entry points past end of file."); report_fatal_error(
"Symbol name entry points before beginning or past end of file.");
Res = StringRef(Start); Res = StringRef(Start);
return object_error::success; return object_error::success;
} }

View File

@ -43,7 +43,7 @@ SMALL-SEGLOADC-SIZE: Segment load command size is too small
INCOMPLETE-LOADC: Malformed MachO file INCOMPLETE-LOADC: Malformed MachO file
TOO-MANY-SECTS: Number of sections too large for size of load command TOO-MANY-SECTS: Number of sections too large for size of load command
BAD-SYMBOL: Requested symbol index is out of range 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-SEG-NAME: getSectionRawFinalSegmentName: Invalid section index
INVALID-SECTION-IDX-SECT-NAME: getSectionRawName: Invalid section index INVALID-SECTION-IDX-SECT-NAME: getSectionRawName: Invalid section index