[llvm] r237628 - [BitcodeReader] Make sure the type of the inserted value matches the type of the aggregate at those indices

Filipe Cabecinhas me at filcab.net
Mon May 18 15:27:12 PDT 2015


Author: filcab
Date: Mon May 18 17:27:11 2015
New Revision: 237628

URL: http://llvm.org/viewvc/llvm-project?rev=237628&view=rev
Log:
[BitcodeReader] Make sure the type of the inserted value matches the type of the aggregate at those indices

Bug found with AFL-fuzz.

Added:
    llvm/trunk/test/Bitcode/Inputs/invalid-inserted-value-type-mismatch.bc
Modified:
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
    llvm/trunk/test/Bitcode/invalid.test

Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=237628&r1=237627&r2=237628&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Mon May 18 17:27:11 2015
@@ -3644,6 +3644,9 @@ std::error_code BitcodeReader::ParseFunc
           CurTy = CurTy->subtypes()[0];
       }
 
+      if (CurTy != Val->getType())
+        return Error("Inserted value type doesn't match aggregate type");
+
       I = InsertValueInst::Create(Agg, Val, INSERTVALIdx);
       InstructionList.push_back(I);
       break;

Added: llvm/trunk/test/Bitcode/Inputs/invalid-inserted-value-type-mismatch.bc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/Inputs/invalid-inserted-value-type-mismatch.bc?rev=237628&view=auto
==============================================================================
Binary files llvm/trunk/test/Bitcode/Inputs/invalid-inserted-value-type-mismatch.bc (added) and llvm/trunk/test/Bitcode/Inputs/invalid-inserted-value-type-mismatch.bc Mon May 18 17:27:11 2015 differ

Modified: llvm/trunk/test/Bitcode/invalid.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/invalid.test?rev=237628&r1=237627&r2=237628&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/invalid.test (original)
+++ llvm/trunk/test/Bitcode/invalid.test Mon May 18 17:27:11 2015
@@ -142,3 +142,8 @@ RUN: not llvm-dis -disable-output %p/Inp
 RUN:   FileCheck --check-prefix=BAD-LOAD-PTR-TYPE %s
 
 BAD-LOAD-PTR-TYPE: Cannot load/store from pointer
+
+RUN: not llvm-dis -disable-output %p/Inputs/invalid-inserted-value-type-mismatch.bc 2>&1 | \
+RUN:   FileCheck --check-prefix=INSERT-TYPE-MISMATCH %s
+
+INSERT-TYPE-MISMATCH: Inserted value type doesn't match aggregate type





More information about the llvm-commits mailing list