diff options
author | Filipe Cabecinhas <me@filcab.net> | 2015-04-14 14:07:15 +0000 |
---|---|---|
committer | Filipe Cabecinhas <me@filcab.net> | 2015-04-14 14:07:15 +0000 |
commit | 225542713b0d5e1c42055e0e77bc56c140100d75 (patch) | |
tree | ee616f640fa5531be7d0c7246cb77681fb44ef11 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | daa4d45c0aa771b999df714a07234979e7746f83 (diff) | |
download | bcm5719-llvm-225542713b0d5e1c42055e0e77bc56c140100d75.tar.gz bcm5719-llvm-225542713b0d5e1c42055e0e77bc56c140100d75.zip |
Error out of ParseBitcodeInto(Module*) if we haven't read a Module
Summary:
Without this check the following case failed:
Skip a SubBlock which is not a MODULE_BLOCK_ID nor a BLOCKINFO_BLOCK_ID
Got to end of file
TheModule would still be == nullptr, and we would subsequentially fail
when materializing the Module (assert at the start of
BitcodeReader::MaterializeModule).
Bug found with AFL.
Reviewers: dexonsmith, rafael
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D9014
llvm-svn: 234887
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 149642b1b3e..bd4d70b25aa 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -3063,8 +3063,12 @@ std::error_code BitcodeReader::ParseBitcodeInto(Module *M, // We expect a number of well-defined blocks, though we don't necessarily // need to understand them all. while (1) { - if (Stream.AtEndOfStream()) - return std::error_code(); + if (Stream.AtEndOfStream()) { + if (TheModule) + return std::error_code(); + // We didn't really read a proper Module. + return Error("Malformed IR file"); + } BitstreamEntry Entry = Stream.advance(BitstreamCursor::AF_DontAutoprocessAbbrevs); |