summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorFilipe Cabecinhas <me@filcab.net>2015-01-24 04:15:05 +0000
committerFilipe Cabecinhas <me@filcab.net>2015-01-24 04:15:05 +0000
commitde968ecb05bd92f14105bbe3b7a19c6bfd69be39 (patch)
tree6767d94927e4ce8c3d33287c6e9ae2264f279eb3 /llvm/lib
parentd1787adcec7f0ffa9ac002c1c04c7fc9c907f245 (diff)
downloadbcm5719-llvm-de968ecb05bd92f14105bbe3b7a19c6bfd69be39.tar.gz
bcm5719-llvm-de968ecb05bd92f14105bbe3b7a19c6bfd69be39.zip
[Bitcode] Diagnose errors instead of asserting from bad input
Eventually we can make some of these pass the error along to the caller. Reports a fatal error if: We find an invalid abbrev record We try to get an invalid abbrev number We can't fill the current word due to an EOF Fixed an invalid bitcode test to check for output with FileCheck Bugs found with afl-fuzz llvm-svn: 226986
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Bitcode/Reader/BitstreamReader.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitstreamReader.cpp b/llvm/lib/Bitcode/Reader/BitstreamReader.cpp
index 5e3232e5313..9d5fab9147a 100644
--- a/llvm/lib/Bitcode/Reader/BitstreamReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitstreamReader.cpp
@@ -170,8 +170,12 @@ unsigned BitstreamCursor::readRecord(unsigned AbbrevID,
unsigned Code;
if (CodeOp.isLiteral())
Code = CodeOp.getLiteralValue();
- else
+ else {
+ if (CodeOp.getEncoding() == BitCodeAbbrevOp::Array ||
+ CodeOp.getEncoding() == BitCodeAbbrevOp::Blob)
+ report_fatal_error("Abbreviation starts with an Array or a Blob");
Code = readAbbreviatedField(*this, CodeOp);
+ }
for (unsigned i = 1, e = Abbv->getNumOperandInfos(); i != e; ++i) {
const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i);
OpenPOWER on IntegriCloud