1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 19:52:54 +01:00

Validate the blocksize before using it

The blocksize could be zero on disk causing later checks to divide by
zero.

llvm-svn: 271008
This commit is contained in:
David Majnemer 2016-05-27 15:57:38 +00:00
parent 67f884d956
commit f36149144f

View File

@ -139,9 +139,10 @@ Error PDBFile::parseFileHeaders() {
return make_error<RawError>(raw_error_code::corrupt_file,
"MSF magic header doesn't match");
if (BufferRef.getBufferSize() % SB->BlockSize != 0)
// We don't support blocksizes which aren't a multiple of four bytes.
if (SB->BlockSize % sizeof(support::ulittle32_t) != 0)
return make_error<RawError>(raw_error_code::corrupt_file,
"File size is not a multiple of block size");
"Block size is not multiple of 4.");
switch (SB->BlockSize) {
case 512: case 1024: case 2048: case 4096:
@ -152,10 +153,9 @@ Error PDBFile::parseFileHeaders() {
"Unsupported block size.");
}
// We don't support blocksizes which aren't a multiple of four bytes.
if (SB->BlockSize % sizeof(support::ulittle32_t) != 0)
if (BufferRef.getBufferSize() % SB->BlockSize != 0)
return make_error<RawError>(raw_error_code::corrupt_file,
"Block size is not multiple of 4.");
"File size is not a multiple of block size");
// We don't support directories whose sizes aren't a multiple of four bytes.
if (SB->NumDirectoryBytes % sizeof(support::ulittle32_t) != 0)