[llvm] r267965 - [llvm-pdbdump] Try to appease the ASan bot

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 28 18:00:17 PDT 2016


Author: majnemer
Date: Thu Apr 28 20:00:17 2016
New Revision: 267965

URL: http://llvm.org/viewvc/llvm-project?rev=267965&view=rev
Log:
[llvm-pdbdump] Try to appease the ASan bot

We didn't check that the file was large enough to hold a super block.

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=267965&r1=267964&r2=267965&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp Thu Apr 28 20:00:17 2016
@@ -122,6 +122,11 @@ std::error_code PDBFile::parseFileHeader
   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);




More information about the llvm-commits mailing list