summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2016-11-02 00:39:11 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2016-11-02 00:39:11 +0000
commitff2c2ec6b225c690234056a16fd1bc07e203ca0e (patch)
tree755f334515b281fb98066e3bbf6dbdd58a01dc87 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parent07b83767a041cbe3dcb5b1ae6144c551e45b33b1 (diff)
downloadbcm5719-llvm-ff2c2ec6b225c690234056a16fd1bc07e203ca0e.tar.gz
bcm5719-llvm-ff2c2ec6b225c690234056a16fd1bc07e203ca0e.zip
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
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 710187af951..954d482c5a9 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -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 ||
OpenPOWER on IntegriCloud