Fix edge case when Start overflowed in 32 bit mode
authorFilipe Cabecinhas <me@filcab.net>
Thu, 15 Jan 2015 23:50:44 +0000 (23:50 +0000)
committerFilipe Cabecinhas <me@filcab.net>
Thu, 15 Jan 2015 23:50:44 +0000 (23:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226229 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Object/MachOObjectFile.cpp
test/Object/macho-invalid.test

index a367a49f6bc7806f012c4cae0168ba6875bfaf8d..4f544074c3df8401a2a7dc1be3868256c5b785df 100644 (file)
@@ -336,8 +336,9 @@ std::error_code MachOObjectFile::getSymbolName(DataRefImpl Symb,
   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;
 }
index 138d8eb1f3dc109c8254b948a170b7856b361eaf..ac4bbeb0da1f5f28ff1fc88044beff2a1043857e 100644 (file)
@@ -43,7 +43,7 @@ SMALL-SEGLOADC-SIZE: Segment load command size is too small
 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