[BitcodeReader] Validate OpNum, before accessing Record array.
Currently invalid bitcode files can cause a crash, when OpNum exceeds the number of elements in Record, like in the attached bitcode file. The test case was generated by clusterfuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=15698 Reviewers: t.p.northover, thegameg, jfb Reviewed By: jfb Differential Revision: https://reviews.llvm.org/D64507 llvm-svn: 365750
This commit is contained in:
@@ -4165,6 +4165,10 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
|
||||
popValue(Record, OpNum, NextValueNo, LHS->getType(), RHS))
|
||||
return error("Invalid record");
|
||||
|
||||
if (OpNum >= Record.size())
|
||||
return error(
|
||||
"Invalid record: operand number exceeded available operands");
|
||||
|
||||
unsigned PredVal = Record[OpNum];
|
||||
bool IsFP = LHS->getType()->isFPOrFPVectorTy();
|
||||
FastMathFlags FMF;
|
||||
|
||||
Reference in New Issue
Block a user