summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Reader
diff options
context:
space:
mode:
authorFilipe Cabecinhas <me@filcab.net>2015-01-30 18:13:50 +0000
committerFilipe Cabecinhas <me@filcab.net>2015-01-30 18:13:50 +0000
commitfcd044b692653de5e79502e556cb652b8867b77f (patch)
treea3bd52f59956c92cadae12131be0311d1b4a8d4d /llvm/lib/Bitcode/Reader
parent709c0a16bbd4ec7dbe1f684f36a861f044f2fc9e (diff)
downloadbcm5719-llvm-fcd044b692653de5e79502e556cb652b8867b77f.tar.gz
bcm5719-llvm-fcd044b692653de5e79502e556cb652b8867b77f.zip
Check bit widths before trying to get a type.
Added a test case for it. Also added run lines for the test case in r227566. Bugs found with afl-fuzz llvm-svn: 227589
Diffstat (limited to 'llvm/lib/Bitcode/Reader')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index c3589bce398..0af344ab557 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -950,12 +950,17 @@ std::error_code BitcodeReader::ParseTypeTableBody() {
case bitc::TYPE_CODE_X86_MMX: // X86_MMX
ResultTy = Type::getX86_MMXTy(Context);
break;
- case bitc::TYPE_CODE_INTEGER: // INTEGER: [width]
+ case bitc::TYPE_CODE_INTEGER: { // INTEGER: [width]
if (Record.size() < 1)
return Error("Invalid record");
- ResultTy = IntegerType::get(Context, Record[0]);
+ uint64_t NumBits = Record[0];
+ if (NumBits < IntegerType::MIN_INT_BITS ||
+ NumBits > IntegerType::MAX_INT_BITS)
+ return Error("Bitwidth for integer type out of range");
+ ResultTy = IntegerType::get(Context, NumBits);
break;
+ }
case bitc::TYPE_CODE_POINTER: { // POINTER: [pointee type] or
// [pointee type, address space]
if (Record.size() < 1)
OpenPOWER on IntegriCloud