Bitcode: Check file size before reading bitcode header.
Should unbreak ocaml binding tests. Also added an llvm-dis test that checks for the same thing. llvm-svn: 285777
This commit is contained in:
@@ -4144,7 +4144,8 @@ std::error_code BitcodeReader::parseModule(uint64_t ResumeBit,
|
||||
/// Helper to read the header common to all bitcode files.
|
||||
static bool hasValidBitcodeHeader(BitstreamCursor &Stream) {
|
||||
// Sniff for the signature.
|
||||
if (Stream.Read(8) != 'B' ||
|
||||
if (!Stream.canSkipToPos(4) ||
|
||||
Stream.Read(8) != 'B' ||
|
||||
Stream.Read(8) != 'C' ||
|
||||
Stream.Read(4) != 0x0 ||
|
||||
Stream.Read(4) != 0xC ||
|
||||
|
||||
Reference in New Issue
Block a user