[PATCH] Avoid crash reading bitcode files with bad abbrev record (bug 20485)

David Majnemer david.majnemer at gmail.com
Thu Jan 15 19:57:47 PST 2015


================
Comment at: lib/Bitcode/Reader/BitstreamReader.cpp:251
@@ -250,1 +250,3 @@
     BitCodeAbbrevOp::Encoding E = (BitCodeAbbrevOp::Encoding)Read(3);
+    if(!BitCodeAbbrevOp::isValidEncoding(E))
+      return true;
----------------
Please insert a space between the 'if' and the parenthesis.

================
Comment at: tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp:414
@@ -413,2 +413,3 @@
     if (Entry.ID == bitc::DEFINE_ABBREV) {
-      Stream.ReadAbbrevRecord();
+      if(Stream.ReadAbbrevRecord())
+        return Error("malformed bitcode file");
----------------
Here as well.

================
Comment at: tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp:415
@@ +414,3 @@
+      if(Stream.ReadAbbrevRecord())
+        return Error("malformed bitcode file");
+
----------------
Perhaps a richer error message? Something like: "malformed bitcode file: bad abbreviation record"

http://reviews.llvm.org/D7003

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






More information about the llvm-commits mailing list