mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-25 10:27:04 +00:00
[BitcodeReader] Check vector size before trying to create a VectorType
Bug found with AFL fuzz git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238891 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1497,6 +1497,8 @@ std::error_code BitcodeReader::ParseTypeTableBody() {
|
|||||||
case bitc::TYPE_CODE_VECTOR: // VECTOR: [numelts, eltty]
|
case bitc::TYPE_CODE_VECTOR: // VECTOR: [numelts, eltty]
|
||||||
if (Record.size() < 2)
|
if (Record.size() < 2)
|
||||||
return Error("Invalid record");
|
return Error("Invalid record");
|
||||||
|
if (Record[0] == 0)
|
||||||
|
return Error("Invalid vector length");
|
||||||
ResultTy = getTypeByID(Record[1]);
|
ResultTy = getTypeByID(Record[1]);
|
||||||
if (!ResultTy || !StructType::isValidElementType(ResultTy))
|
if (!ResultTy || !StructType::isValidElementType(ResultTy))
|
||||||
return Error("Invalid type");
|
return Error("Invalid type");
|
||||||
|
|||||||
BIN
test/Bitcode/Inputs/invalid-vector-length.bc
Normal file
BIN
test/Bitcode/Inputs/invalid-vector-length.bc
Normal file
Binary file not shown.
@@ -192,3 +192,8 @@ RUN: not llvm-dis -disable-output %p/Inputs/invalid-metadata-not-followed-named-
|
|||||||
RUN: FileCheck --check-prefix=META-NOT-FOLLOWED-BY-NAMED-META %s
|
RUN: FileCheck --check-prefix=META-NOT-FOLLOWED-BY-NAMED-META %s
|
||||||
|
|
||||||
META-NOT-FOLLOWED-BY-NAMED-META: METADATA_NAME not followed by METADATA_NAMED_NODE
|
META-NOT-FOLLOWED-BY-NAMED-META: METADATA_NAME not followed by METADATA_NAMED_NODE
|
||||||
|
|
||||||
|
RUN: not llvm-dis -disable-output %p/Inputs/invalid-vector-length.bc 2>&1 | \
|
||||||
|
RUN: FileCheck --check-prefix=VECTOR-LENGTH %s
|
||||||
|
|
||||||
|
VECTOR-LENGTH: Invalid vector length
|
||||||
|
|||||||
Reference in New Issue
Block a user