[llvm] r268084 - Fix crash in PDB when loading corrupt file.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 29 11:09:20 PDT 2016
Author: zturner
Date: Fri Apr 29 13:09:19 2016
New Revision: 268084
URL: http://llvm.org/viewvc/llvm-project?rev=268084&view=rev
Log:
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.
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=268084&r1=268083&r2=268084&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp Fri Apr 29 13:09:19 2016
@@ -123,6 +123,13 @@ std::error_code PDBFile::parseFileHeader
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))
More information about the llvm-commits
mailing list