forked from OSchip/llvm-project
[BitcodeReader] Validate Strtab before accessing.
This fixes a crash with invalid bitcode files that have records referencing names in Strtab, but Strtab is not present or the index is out-of-bounds. This fixes the following clusterfuzz issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29895 Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D95554
This commit is contained in:
parent
e638a290f7
commit
34cccdaed7
|
@ -3407,9 +3407,12 @@ Error BitcodeReader::parseFunctionRecord(ArrayRef<uint64_t> Record) {
|
|||
|
||||
// Record[16] is the address space number.
|
||||
|
||||
// Check whether we have enough values to read a partition name.
|
||||
if (Record.size() > 18)
|
||||
// Check whether we have enough values to read a partition name. Also make
|
||||
// sure Strtab has enough values.
|
||||
if (Record.size() > 18 && Strtab.data() &&
|
||||
Record[17] + Record[18] <= Strtab.size()) {
|
||||
Func->setPartition(StringRef(Strtab.data() + Record[17], Record[18]));
|
||||
}
|
||||
|
||||
ValueList.push_back(Func);
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
; Bitcode with an invalid record that indexes a name outside of strtab.
|
||||
|
||||
; RUN: not llvm-dis %s.bc -o - 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: error: Invalid record
|
Binary file not shown.
Loading…
Reference in New Issue