[PATCH] Be more strict about the operand for the array type in BitcodeReader
Filipe Cabecinhas
filcab+llvm.phabricator at gmail.com
Tue Apr 14 07:56:50 PDT 2015
Hi rafael,
Bug found with AFL.
http://reviews.llvm.org/D9016
Files:
lib/Bitcode/Reader/BitstreamReader.cpp
test/Bitcode/Inputs/invalid-array-type.bc
test/Bitcode/invalid.test
Index: lib/Bitcode/Reader/BitstreamReader.cpp
===================================================================
--- lib/Bitcode/Reader/BitstreamReader.cpp
+++ lib/Bitcode/Reader/BitstreamReader.cpp
@@ -197,6 +197,9 @@
// Get the element encoding.
assert(i+2 == e && "array op not second to last?");
const BitCodeAbbrevOp &EltEnc = Abbv->getOperandInfo(++i);
+ if (EltEnc.getEncoding() == BitCodeAbbrevOp::Array ||
+ EltEnc.getEncoding() == BitCodeAbbrevOp::Blob)
+ report_fatal_error("Array element type can't be an Array or a Blob");
// Read all the elements.
for (; NumElts; --NumElts)
Index: test/Bitcode/invalid.test
===================================================================
--- test/Bitcode/invalid.test
+++ test/Bitcode/invalid.test
@@ -55,3 +55,8 @@
RUN: FileCheck --check-prefix=NO-MODULE %s
NO-MODULE: Malformed IR file
+
+RUN: not llvm-dis -disable-output %p/Inputs/invalid-array-type.bc 2>&1 | \
+RUN: FileCheck --check-prefix=ARRAY-TYPE %s
+
+ARRAY-TYPE: Array element type can't be an Array or a Blob
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9016.23734.patch
Type: text/x-patch
Size: 1092 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150414/a94fe3f0/attachment.bin>
More information about the llvm-commits
mailing list