[llvm] r290053 - [PDB] Validate superblock addresses
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 17 16:41:11 PST 2016
Author: majnemer
Date: Sat Dec 17 18:41:10 2016
New Revision: 290053
URL: http://llvm.org/viewvc/llvm-project?rev=290053&view=rev
Log:
[PDB] Validate superblock addresses
- Validate the address of the block map.
- Validate the address of the free block map.
Modified:
llvm/trunk/lib/DebugInfo/MSF/MSFCommon.cpp
llvm/trunk/unittests/DebugInfo/PDB/MSFBuilderTest.cpp
Modified: llvm/trunk/lib/DebugInfo/MSF/MSFCommon.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/MSF/MSFCommon.cpp?rev=290053&r1=290052&r2=290053&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/MSF/MSFCommon.cpp (original)
+++ llvm/trunk/lib/DebugInfo/MSF/MSFCommon.cpp Sat Dec 17 18:41:10 2016
@@ -44,5 +44,14 @@ Error llvm::msf::validateSuperBlock(cons
return make_error<MSFError>(msf_error_code::invalid_format,
"Block 0 is reserved");
+ if (SB.BlockMapAddr >= SB.NumBlocks)
+ return make_error<MSFError>(msf_error_code::invalid_format,
+ "Block map address is invalid.");
+
+ if (SB.FreeBlockMapBlock != 1 && SB.FreeBlockMapBlock != 2)
+ return make_error<MSFError>(
+ msf_error_code::invalid_format,
+ "The free block map isn't at block 1 or block 2.");
+
return Error::success();
}
Modified: llvm/trunk/unittests/DebugInfo/PDB/MSFBuilderTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/PDB/MSFBuilderTest.cpp?rev=290053&r1=290052&r2=290053&view=diff
==============================================================================
--- llvm/trunk/unittests/DebugInfo/PDB/MSFBuilderTest.cpp (original)
+++ llvm/trunk/unittests/DebugInfo/PDB/MSFBuilderTest.cpp Sat Dec 17 18:41:10 2016
@@ -30,6 +30,7 @@ protected:
::memset(&SB, 0, sizeof(SB));
::memcpy(SB.MagicBytes, msf::Magic, sizeof(msf::Magic));
+ SB.FreeBlockMapBlock = 1;
SB.BlockMapAddr = 1;
SB.BlockSize = 4096;
SB.NumDirectoryBytes = 0;
More information about the llvm-commits
mailing list