[llvm] r227566 - [bitcode reader] Fix an assert on invalid type tables
Filipe Cabecinhas
me at filcab.net
Fri Jan 30 02:57:59 PST 2015
Author: filcab
Date: Fri Jan 30 04:57:58 2015
New Revision: 227566
URL: http://llvm.org/viewvc/llvm-project?rev=227566&view=rev
Log:
[bitcode reader] Fix an assert on invalid type tables
Bug found with afl-fuzz
Added:
llvm/trunk/test/Bitcode/Inputs/invalid-type-table-forward-ref.bc
Modified:
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=227566&r1=227565&r2=227566&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Fri Jan 30 04:57:58 2015
@@ -1095,8 +1095,10 @@ std::error_code BitcodeReader::ParseType
if (NumRecords >= TypeList.size())
return Error("Invalid TYPE table");
+ if (TypeList[NumRecords])
+ return Error(
+ "Invalid TYPE table: Only named structs can be forward referenced");
assert(ResultTy && "Didn't read a type?");
- assert(!TypeList[NumRecords] && "Already read type?");
TypeList[NumRecords++] = ResultTy;
}
}
Added: llvm/trunk/test/Bitcode/Inputs/invalid-type-table-forward-ref.bc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/Inputs/invalid-type-table-forward-ref.bc?rev=227566&view=auto
==============================================================================
Binary files llvm/trunk/test/Bitcode/Inputs/invalid-type-table-forward-ref.bc (added) and llvm/trunk/test/Bitcode/Inputs/invalid-type-table-forward-ref.bc Fri Jan 30 04:57:58 2015 differ
More information about the llvm-commits
mailing list