From: Filipe Cabecinhas Date: Tue, 26 May 2015 23:52:21 +0000 (+0000) Subject: [BitcodeReader] Make sure abbrev records have at least one operand (record code) X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c756772b8d69b5d5cf1f84a44d887eacd60f3d3d;p=oota-llvm.git [BitcodeReader] Make sure abbrev records have at least one operand (record code) Bug found with AFL fuzz. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238265 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Bitcode/Reader/BitstreamReader.cpp b/lib/Bitcode/Reader/BitstreamReader.cpp index 3b03f4b12b8..2d02549ce4e 100644 --- a/lib/Bitcode/Reader/BitstreamReader.cpp +++ b/lib/Bitcode/Reader/BitstreamReader.cpp @@ -282,6 +282,9 @@ void BitstreamCursor::ReadAbbrevRecord() { } else Abbv->Add(BitCodeAbbrevOp(E)); } + + if (Abbv->getNumOperandInfos() == 0) + report_fatal_error("Abbrev record with no operands"); CurAbbrevs.push_back(Abbv); } diff --git a/test/Bitcode/Inputs/invalid-abbrev-no-operands.bc b/test/Bitcode/Inputs/invalid-abbrev-no-operands.bc new file mode 100644 index 00000000000..29af122e94e Binary files /dev/null and b/test/Bitcode/Inputs/invalid-abbrev-no-operands.bc differ diff --git a/test/Bitcode/invalid.test b/test/Bitcode/invalid.test index bd6e265cbb3..9c9d54fad6c 100644 --- a/test/Bitcode/invalid.test +++ b/test/Bitcode/invalid.test @@ -172,3 +172,8 @@ RUN: not llvm-dis -disable-output %p/Inputs/invalid-global-var-comdat-id.bc 2>&1 RUN: FileCheck --check-prefix=INVALID-GVCOMDAT-ID %s INVALID-GVCOMDAT-ID: Invalid global variable comdat ID + +RUN: not llvm-dis -disable-output %p/Inputs/invalid-abbrev-no-operands.bc 2>&1 | \ +RUN: FileCheck --check-prefix=ABBREV-NO-OPS %s + +ABBREV-NO-OPS: Abbrev record with no operands