[PDB] Validate superblock addresses

- 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
This commit is contained in:
David Majnemer 2016-12-18 00:41:10 +00:00
parent 0f11f29f4b
commit 9b671f3db3
2 changed files with 10 additions and 0 deletions

View File

@ -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();
}

View File

@ -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;