[llvm-commits] [llvm] r100156 - /llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
Dan Gohman
gohman at apple.com
Thu Apr 1 17:03:52 PDT 2010
Author: djg
Date: Thu Apr 1 19:03:51 2010
New Revision: 100156
URL: http://llvm.org/viewvc/llvm-project?rev=100156&view=rev
Log:
If the bitcode reader input stream isn't a multiple of 4 bytes, it's more
likely not a bitcode file at all, rather than being a bitcode file which
is truncated. Check for this case and issue a more relevant error message.
Modified:
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=100156&r1=100155&r2=100156&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Thu Apr 1 19:03:51 2010
@@ -1527,12 +1527,16 @@
bool BitcodeReader::ParseBitcodeInto(Module *M) {
TheModule = 0;
- if (Buffer->getBufferSize() & 3)
- return Error("Bitcode stream should be a multiple of 4 bytes in length");
-
unsigned char *BufPtr = (unsigned char *)Buffer->getBufferStart();
unsigned char *BufEnd = BufPtr+Buffer->getBufferSize();
+ if (Buffer->getBufferSize() & 3) {
+ if (!isRawBitcode(BufPtr, BufEnd) && !isBitcodeWrapper(BufPtr, BufEnd))
+ return Error("Invalid bitcode signature");
+ else
+ return Error("Bitcode stream should be a multiple of 4 bytes in length");
+ }
+
// If we have a wrapper header, parse it and ignore the non-bc file contents.
// The magic number is 0x0B17C0DE stored in little endian.
if (isBitcodeWrapper(BufPtr, BufEnd))
More information about the llvm-commits
mailing list