[llvm] r236027 - Relax an assert when there's a type mismatch in forward references
Filipe Cabecinhas
me at filcab.net
Tue Apr 28 13:18:48 PDT 2015
Author: filcab
Date: Tue Apr 28 15:18:47 2015
New Revision: 236027
URL: http://llvm.org/viewvc/llvm-project?rev=236027&view=rev
Log:
Relax an assert when there's a type mismatch in forward references
Summary:
We don't seem to need to assert here, since this function's callers expect
to get a nullptr on error. This way we don't assert on user input.
Bug found with AFL fuzz.
Reviewers: rafael
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D9308
Added:
llvm/trunk/test/Bitcode/Inputs/invalid-fwdref-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=236027&r1=236026&r2=236027&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Tue Apr 28 15:18:47 2015
@@ -794,7 +794,9 @@ Value *BitcodeReaderValueList::getValueF
resize(Idx + 1);
if (Value *V = ValuePtrs[Idx]) {
- assert((!Ty || Ty == V->getType()) && "Type mismatch in value table!");
+ // If the types don't match, it's invalid.
+ if (Ty && Ty != V->getType())
+ return nullptr;
return V;
}
Added: llvm/trunk/test/Bitcode/Inputs/invalid-fwdref-type-mismatch.bc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/Inputs/invalid-fwdref-type-mismatch.bc?rev=236027&view=auto
==============================================================================
Binary files llvm/trunk/test/Bitcode/Inputs/invalid-fwdref-type-mismatch.bc (added) and llvm/trunk/test/Bitcode/Inputs/invalid-fwdref-type-mismatch.bc Tue Apr 28 15:18:47 2015 differ
Modified: llvm/trunk/test/Bitcode/invalid.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/invalid.test?rev=236027&r1=236026&r2=236027&view=diff
==============================================================================
--- llvm/trunk/test/Bitcode/invalid.test (original)
+++ llvm/trunk/test/Bitcode/invalid.test Tue Apr 28 15:18:47 2015
@@ -93,3 +93,8 @@ RUN: not llvm-dis -disable-output %p/Inp
RUN: FileCheck --check-prefix=INVALID-TYPE %s
INVALID-TYPE: Invalid type for value
+
+RUN: not llvm-dis -disable-output %p/Inputs/invalid-fwdref-type-mismatch.bc 2>&1 | \
+RUN: FileCheck --check-prefix=FWDREF-TYPE %s
+
+FWDREF-TYPE: Invalid record
More information about the llvm-commits
mailing list