summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-05-27 15:57:38 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-05-27 15:57:38 +0000
commit878cadb663fd8c8033a7b93f932d862266093fc9 (patch)
tree6e1bd934ae580f4a83fe097baa5bb19b081ec75d
parent7e67a22298413565b4835bc12851c2d95b2fb288 (diff)
downloadbcm5719-llvm-878cadb663fd8c8033a7b93f932d862266093fc9.tar.gz
bcm5719-llvm-878cadb663fd8c8033a7b93f932d862266093fc9.zip
Validate the blocksize before using it
The blocksize could be zero on disk causing later checks to divide by zero. llvm-svn: 271008
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp
index 594739f4b88..b04ccab0cb4 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp
@@ -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)
OpenPOWER on IntegriCloud