[llvm] r238265 - [BitcodeReader] Make sure abbrev records have at least one operand (record code)
Filipe Cabecinhas
me at filcab.net
Tue May 26 16:52:22 PDT 2015
Author: filcab
Date: Tue May 26 18:52:21 2015
New Revision: 238265
URL: http://llvm.org/viewvc/llvm-project?rev=238265&view=rev
Log:
[BitcodeReader] Make sure abbrev records have at least one operand (record code)
Bug found with AFL fuzz.
Added:
llvm/trunk/test/Bitcode/Inputs/invalid-abbrev-no-operands.bc
Modified:
llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp
llvm/trunk/test/Bitcode/invalid.test
Modified: llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp?rev=238265&r1=238264&r2=238265&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp Tue May 26 18:52:21 2015
@@ -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);
}
Added: llvm/trunk/test/Bitcode/Inputs/invalid-abbrev-no-operands.bc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/Inputs/invalid-abbrev-no-operands.bc?rev=238265&view=auto
==============================================================================
Binary files llvm/trunk/test/Bitcode/Inputs/invalid-abbrev-no-operands.bc (added) and llvm/trunk/test/Bitcode/Inputs/invalid-abbrev-no-operands.bc Tue May 26 18:52:21 2015 differ
Modified: llvm/trunk/test/Bitcode/invalid.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/invalid.test?rev=238265&r1=238264&r2=238265&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/invalid.test (original)
+++ llvm/trunk/test/Bitcode/invalid.test Tue May 26 18:52:21 2015
@@ -172,3 +172,8 @@ RUN: not llvm-dis -disable-output %p/Inp
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
More information about the llvm-commits
mailing list