Skip to content

Commit

Permalink
Don't overflow GCTable
Browse files Browse the repository at this point in the history
Summary: Bug found with AFL fuzz.

Reviewers: rafael, dexonsmith

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D9361

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236200 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
filcab committed Apr 30, 2015
1 parent 36a398f commit deedba2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Bitcode/Reader/BitcodeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2992,7 +2992,7 @@ std::error_code BitcodeReader::ParseModule(bool Resume,
// FIXME: Change to an error if non-default in 4.0.
Func->setVisibility(GetDecodedVisibility(Record[7]));
if (Record.size() > 8 && Record[8]) {
if (Record[8]-1 > GCTable.size())
if (Record[8]-1 >= GCTable.size())
return Error("Invalid ID");
Func->setGC(GCTable[Record[8]-1].c_str());
}
Expand Down
Binary file added test/Bitcode/Inputs/invalid-GCTable-overflow.bc
Binary file not shown.
5 changes: 5 additions & 0 deletions test/Bitcode/invalid.test
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,8 @@ RUN: not llvm-dis -disable-output %p/Inputs/invalid-load-pointer-type.bc 2>&1 |
RUN: FileCheck --check-prefix=LOAD-BAD-TYPE %s

LOAD-BAD-TYPE: Load operand is not a pointer type

RUN: not llvm-dis -disable-output %p/Inputs/invalid-GCTable-overflow.bc 2>&1 | \
RUN: FileCheck --check-prefix=GCTABLE-OFLOW %s

GCTABLE-OFLOW: Invalid ID

0 comments on commit deedba2

Please sign in to comment.