mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
Verify sizes when trying to read a VBR
Also added an assert to ReadVBR64. llvm-svn: 234984
This commit is contained in:
parent
066194e0a6
commit
612f7a52fa
@ -395,6 +395,7 @@ public:
|
||||
// Read a VBR that may have a value up to 64-bits in size. The chunk size of
|
||||
// the VBR must still be <= 32 bits though.
|
||||
uint64_t ReadVBR64(unsigned NumBits) {
|
||||
assert(NumBits <= 64 && "VBR can only be up to 64 bits in size.");
|
||||
uint32_t Piece = Read(NumBits);
|
||||
if ((Piece & (1U << (NumBits-1))) == 0)
|
||||
return uint64_t(Piece);
|
||||
|
@ -62,6 +62,8 @@ static uint64_t readAbbreviatedField(BitstreamCursor &Cursor,
|
||||
case BitCodeAbbrevOp::Fixed:
|
||||
return Cursor.Read((unsigned)Op.getEncodingData());
|
||||
case BitCodeAbbrevOp::VBR:
|
||||
if ((unsigned)Op.getEncodingData() > 64)
|
||||
report_fatal_error("Invalid record");
|
||||
return Cursor.ReadVBR64((unsigned)Op.getEncodingData());
|
||||
case BitCodeAbbrevOp::Char6:
|
||||
return BitCodeAbbrevOp::DecodeChar6(Cursor.Read(6));
|
||||
|
BIN
test/Bitcode/Inputs/invalid-VBR-too-big.bc
Normal file
BIN
test/Bitcode/Inputs/invalid-VBR-too-big.bc
Normal file
Binary file not shown.
@ -55,3 +55,8 @@ RUN: not llvm-dis -disable-output %p/Inputs/invalid-no-proper-module.bc 2>&1 | \
|
||||
RUN: FileCheck --check-prefix=NO-MODULE %s
|
||||
|
||||
NO-MODULE: Malformed IR file
|
||||
|
||||
RUN: not llvm-dis -disable-output %p/Inputs/invalid-VBR-too-big.bc 2>&1 | \
|
||||
RUN: FileCheck --check-prefix=HUGE-VBR %s
|
||||
|
||||
HUGE-VBR: Invalid record
|
||||
|
Loading…
Reference in New Issue
Block a user