diff options
author | Zachary Turner <zturner@google.com> | 2016-05-02 22:16:57 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2016-05-02 22:16:57 +0000 |
commit | d6192f482ffa7c3162b60aa0c68b5ea38e350a11 (patch) | |
tree | 7e41572dda5aad98edfd7ee6cca627b695a0335a /llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp | |
parent | bda9b2ae9e69e5de7ce76e70c9cd6519d90a0226 (diff) | |
download | llvm-d6192f482ffa7c3162b60aa0c68b5ea38e350a11.zip llvm-d6192f482ffa7c3162b60aa0c68b5ea38e350a11.tar.gz llvm-d6192f482ffa7c3162b60aa0c68b5ea38e350a11.tar.bz2 |
[llvm-pdbdump] Fix read past EOF when file is too small.
llvm-svn: 268316
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp index f9ce344..df47ced 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp @@ -119,6 +119,8 @@ StringRef PDBFile::getBlockData(uint32_t BlockIndex, uint32_t NumBytes) const { std::error_code PDBFile::parseFileHeaders() { std::error_code EC; MemoryBufferRef BufferRef = *Context->Buffer; + if (BufferRef.getBufferSize() < sizeof(SuperBlock)) + return std::make_error_code(std::errc::illegal_byte_sequence); Context->SB = reinterpret_cast<const SuperBlock *>(BufferRef.getBufferStart()); @@ -130,6 +132,8 @@ std::error_code PDBFile::parseFileHeaders() { // An invalid block size suggests a corrupt PDB file. return std::make_error_code(std::errc::illegal_byte_sequence); } + if (BufferRef.getBufferSize() % SB->BlockSize != 0) + return std::make_error_code(std::errc::illegal_byte_sequence); // Make sure the file is sufficiently large to hold a super block. if (BufferRef.getBufferSize() < sizeof(SuperBlock)) |