diff options
author | Zachary Turner <zturner@google.com> | 2016-04-29 18:09:19 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2016-04-29 18:09:19 +0000 |
commit | 9213ba530432bd57b647aa90ea65a735a6d40334 (patch) | |
tree | 788e833d24215121c35a2eecd3e60c3dbb3e2425 /llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp | |
parent | 7736a208b8958a7e708c0756bdce40437f8f48f6 (diff) | |
download | llvm-9213ba530432bd57b647aa90ea65a735a6d40334.zip llvm-9213ba530432bd57b647aa90ea65a735a6d40334.tar.gz llvm-9213ba530432bd57b647aa90ea65a735a6d40334.tar.bz2 |
Fix crash in PDB when loading corrupt file.
There are probably hundreds of crashers we can find by fuzzing
more. For now we do the simplest possible validation of the
block size. Later, more complicated validations can verify that
other fields of the super block such as directory size, number
of blocks, agree with the size of the file etc.
llvm-svn: 268084
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp index 6e5f536..f9ce344 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp @@ -123,6 +123,13 @@ std::error_code PDBFile::parseFileHeaders() { Context->SB = reinterpret_cast<const SuperBlock *>(BufferRef.getBufferStart()); const SuperBlock *SB = Context->SB; + switch (SB->BlockSize) { + case 512: case 1024: case 2048: case 4096: + break; + default: + // An invalid block size suggests a corrupt PDB file. + 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)) |