Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 3b82115

Browse files
committed
[BitcodeReader] Change an assert to a call to a call to Error()
It's reachable from user input. Bug found with AFL fuzz. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238633 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent dbf84c9 commit 3b82115

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,9 +1634,9 @@ std::error_code BitcodeReader::ParseMetadata() {
16341634
Record.clear();
16351635
Code = Stream.ReadCode();
16361636

1637-
// METADATA_NAME is always followed by METADATA_NAMED_NODE.
16381637
unsigned NextBitCode = Stream.readRecord(Code, Record);
1639-
assert(NextBitCode == bitc::METADATA_NAMED_NODE); (void)NextBitCode;
1638+
if (NextBitCode != bitc::METADATA_NAMED_NODE)
1639+
return Error("METADATA_NAME not followed by METADATA_NAMED_NODE");
16401640

16411641
// Read named metadata elements.
16421642
unsigned Size = Record.size();
Binary file not shown.

test/Bitcode/invalid.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,8 @@ RUN: not llvm-dis -disable-output %p/Inputs/invalid-array-operand-encoding.bc 2>
187187
RUN: FileCheck --check-prefix=ARRAY-OP-ENC %s
188188

189189
ARRAY-OP-ENC: Array element type has to be an encoding of a type
190+
191+
RUN: not llvm-dis -disable-output %p/Inputs/invalid-metadata-not-followed-named-node.bc 2>&1 | \
192+
RUN: FileCheck --check-prefix=META-NOT-FOLLOWED-BY-NAMED-META %s
193+
194+
META-NOT-FOLLOWED-BY-NAMED-META: METADATA_NAME not followed by METADATA_NAMED_NODE

0 commit comments

Comments
 (0)