diff options
-rw-r--r-- | llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp | 2 | ||||
-rw-r--r-- | llvm/test/DebugInfo/PDB/Inputs/bad-block-size.pdb | 2 | ||||
-rw-r--r-- | llvm/test/DebugInfo/PDB/pdbdump-headers.test | 3 | ||||
-rw-r--r-- | llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp | 37 |
4 files changed, 29 insertions, 15 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp index 6fefafe597c..be1368eb94f 100644 --- a/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp +++ b/llvm/lib/DebugInfo/PDB/Raw/PDBFile.cpp @@ -127,7 +127,7 @@ std::error_code PDBFile::parseFileHeaders() { return std::make_error_code(std::errc::illegal_byte_sequence); // We don't support blocksizes which aren't a multiple of four bytes. - if (SB->BlockSize % sizeof(support::ulittle32_t) != 0) + if (SB->BlockSize == 0 || SB->BlockSize % sizeof(support::ulittle32_t) != 0) return std::make_error_code(std::errc::not_supported); // We don't support directories whose sizes aren't a multiple of four bytes. diff --git a/llvm/test/DebugInfo/PDB/Inputs/bad-block-size.pdb b/llvm/test/DebugInfo/PDB/Inputs/bad-block-size.pdb new file mode 100644 index 00000000000..fadd8833e4b --- /dev/null +++ b/llvm/test/DebugInfo/PDB/Inputs/bad-block-size.pdb @@ -0,0 +1,2 @@ +Microsoft C/C++ MSF 7.00
+DS
\ No newline at end of file diff --git a/llvm/test/DebugInfo/PDB/pdbdump-headers.test b/llvm/test/DebugInfo/PDB/pdbdump-headers.test index d6d4bcda242..92999827e45 100644 --- a/llvm/test/DebugInfo/PDB/pdbdump-headers.test +++ b/llvm/test/DebugInfo/PDB/pdbdump-headers.test @@ -1,5 +1,6 @@ ; RUN: llvm-pdbdump --dump-headers %p/Inputs/empty.pdb | FileCheck -check-prefix=EMPTY %s ; RUN: llvm-pdbdump --dump-headers %p/Inputs/big-read.pdb | FileCheck -check-prefix=BIG %s +; RUN: llvm-pdbdump --dump-headers %p/Inputs/bad-block-size.pdb | FileCheck -check-prefix=BAD-BLOCK-SIZE %s ; EMPTY: BlockSize: 4096 ; EMPTY-NEXT: Unknown0: 2 @@ -977,3 +978,5 @@ BIG-NEXT: Symbol Byte Size: 3080 BIG-NEXT: Type Server Index: 0 BIG-NEXT: Has EC Info: 0 BIG-NEXT: 0 Contributing Source Files: + +BAD-BLOCK-SIZE: The file has an unrecognized format. diff --git a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp index 4d4987611b9..b91d8685715 100644 --- a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp +++ b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp @@ -308,20 +308,7 @@ static void dumpStructure(RawSession &RS) { } } -static void dumpInput(StringRef Path) { - std::unique_ptr<IPDBSession> Session; - if (opts::DumpHeaders || !opts::DumpStreamData.empty()) { - PDB_ErrorCode Error = loadDataForPDB(PDB_ReaderType::Raw, Path, Session); - if (Error == PDB_ErrorCode::Success) { - RawSession *RS = static_cast<RawSession *>(Session.get()); - dumpStructure(*RS); - } - - outs().flush(); - return; - } - - PDB_ErrorCode Error = loadDataForPDB(PDB_ReaderType::DIA, Path, Session); +static void reportError(StringRef Path, PDB_ErrorCode Error) { switch (Error) { case PDB_ErrorCode::Success: break; @@ -347,6 +334,28 @@ static void dumpInput(StringRef Path) { << "'. An unknown error occured.\n"; return; } +} + +static void dumpInput(StringRef Path) { + std::unique_ptr<IPDBSession> Session; + if (opts::DumpHeaders || !opts::DumpStreamData.empty()) { + PDB_ErrorCode Error = loadDataForPDB(PDB_ReaderType::Raw, Path, Session); + if (Error == PDB_ErrorCode::Success) { + RawSession *RS = static_cast<RawSession *>(Session.get()); + dumpStructure(*RS); + } + + reportError(Path, Error); + outs().flush(); + return; + } + + PDB_ErrorCode Error = loadDataForPDB(PDB_ReaderType::DIA, Path, Session); + if (Error != PDB_ErrorCode::Success) { + reportError(Path, Error); + return; + } + if (opts::LoadAddress) Session->setLoadAddress(opts::LoadAddress); |