[PATCH] Report fatal errors instead of segfaulting/asserting on a few invalid accesses while reading MachO files.

Rafael Ávila de Espíndola rafael.espindola at gmail.com
Wed Jan 14 10:49:49 PST 2015


================
Comment at: lib/Object/MachOObjectFile.cpp:55
@@ +54,3 @@
+template <typename SegmentCmd>
+static uint32_t getSegmentLoadCommandNumSections(SegmentCmd S,
+                                                 uint32_t Cmdsize) {
----------------
Maybe pass a "const SegmentCmd&"?

================
Comment at: lib/Object/MachOObjectFile.cpp:2234
@@ -2205,1 +2233,3 @@
+  if (Load.C.cmdsize < 8)
+    report_fatal_error("Load command with size < 8 bytes.");
   return Load;
----------------
Missing test.

================
Comment at: lib/Object/MachOObjectFile.cpp:2244
@@ -2213,1 +2243,3 @@
+  if (Next.C.cmdsize < 8)
+    report_fatal_error("Load command with size < 8 bytes.");
   return Next;
----------------
Missing test.

================
Comment at: test/Object/macho-invalid.test:33
@@ +32,2 @@
+
+INVALID-SEGMENT-SECTION-IDX: Invalid section index
----------------
There are 4 errors that would match " Invalid section index": Please make sure they are all covered.

http://reviews.llvm.org/D6945

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list