[llvm] r271012 - Make sure there are enough blocks for the stream
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Fri May 27 09:16:49 PDT 2016
Author: majnemer
Date: Fri May 27 11:16:48 2016
New Revision: 271012
URL: http://llvm.org/viewvc/llvm-project?rev=271012&view=rev
Log:
Make sure there are enough blocks for the stream
Modified:
llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp
Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp?rev=271012&r1=271011&r2=271012&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp Fri May 27 11:16:48 2016
@@ -257,10 +257,28 @@ Error PDBFile::parseStreamData() {
return make_error<RawError>(raw_error_code::corrupt_file,
"Orphaned block found?");
+ uint64_t BlockOffset = blockToOffset(Data, getBlockSize());
+ if (BlockOffset + getBlockSize() < BlockOffset)
+ return make_error<RawError>(raw_error_code::corrupt_file,
+ "Bogus stream block number");
+ if (BlockOffset + getBlockSize() > M.getBufferSize())
+ return make_error<RawError>(raw_error_code::corrupt_file,
+ "Stream block number is out of bounds");
+
StreamBlocks->push_back(Data);
}
}
+ for (uint32_t SI = 0; SI != NumStreams; ++SI) {
+ uint64_t NumExpectedStreamBlocks =
+ bytesToBlocks(getStreamByteSize(SI), getBlockSize());
+ size_t NumStreamBlocks = getStreamBlockList(SI).size();
+ if (NumExpectedStreamBlocks != NumStreamBlocks)
+ return make_error<RawError>(raw_error_code::corrupt_file,
+ "The number of stream blocks is not "
+ "sufficient for the size of this stream");
+ }
+
// We should have read exactly SB->NumDirectoryBytes bytes.
assert(DirectoryBytesRead == SB->NumDirectoryBytes);
return Error::success();
More information about the llvm-commits
mailing list