Skip to content

Commit

Permalink
[PDB] Validate superblock addresses
Browse files Browse the repository at this point in the history
- Validate the address of the block map.
- Validate the address of the free block map.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290053 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
majnemer committed Dec 18, 2016
1 parent 0f11f29 commit 9b671f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/DebugInfo/MSF/MSFCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,14 @@ Error llvm::msf::validateSuperBlock(const SuperBlock &SB) {
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();
}
1 change: 1 addition & 0 deletions unittests/DebugInfo/PDB/MSFBuilderTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class MSFBuilderTest : public testing::Test {
::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;
Expand Down

0 comments on commit 9b671f3

Please sign in to comment.