[PATCH] [lld] Fix heap-buffer-overflow bugs identified by the Address Sanitizer

Rafael Ávila de Espíndola rafael.espindola at gmail.com
Wed Feb 18 15:04:11 PST 2015


It needs a testcase.


REPOSITORY
  rL LLVM

================
Comment at: lib/ReaderWriter/MachO/ArchHandler.cpp:145
@@ -144,1 +144,3 @@
   assert(atom->contentType() == DefinedAtom::typeCFI);
+  if (atom->rawContent().size() < sizeof(uint32_t)) {
+    return false;
----------------
You don't need the '{'

================
Comment at: lib/ReaderWriter/MachO/CompactUnwindPass.cpp:414
@@ -413,6 +413,3 @@
 
-    using normalized::read32;
-    entry.rangeLength =
-        read32(atom->rawContent().data() + 2 * sizeof(uint32_t), _isBig);
-    entry.encoding =
-        read32(atom->rawContent().data() + 3 * sizeof(uint32_t), _isBig);
+    if (atom->rawContent().size() > 4 * sizeof(uint32_t)) {
+      using normalized::read32;
----------------
Use an early return maybe?

http://reviews.llvm.org/D7733

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






More information about the llvm-commits mailing list