summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp
index be1368eb94f..0adabfe625c 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp
@@ -122,6 +122,11 @@ std::error_code PDBFile::parseFileHeaders() {
Context->SB =
reinterpret_cast<const SuperBlock *>(BufferRef.getBufferStart());
const SuperBlock *SB = Context->SB;
+
+ // Make sure the file is sufficiently large to hold a super block.
+ if (BufferRef.getBufferSize() < sizeof(SuperBlock))
+ return std::make_error_code(std::errc::illegal_byte_sequence);
+
// Check the magic bytes.
if (memcmp(SB->MagicBytes, Magic, sizeof(Magic)) != 0)
return std::make_error_code(std::errc::illegal_byte_sequence);
OpenPOWER on IntegriCloud