From f72bd6fe60075b4087133bace2dd885de4751c2d Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Mon, 6 Jun 2016 23:19:23 +0000 Subject: [PATCH] [pdbdump] Verify the size of TPI hash records. llvm-svn: 271954 --- lib/DebugInfo/PDB/Raw/TpiStream.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/DebugInfo/PDB/Raw/TpiStream.cpp b/lib/DebugInfo/PDB/Raw/TpiStream.cpp index 8b9b7c81f62..11e10a58e5d 100644 --- a/lib/DebugInfo/PDB/Raw/TpiStream.cpp +++ b/lib/DebugInfo/PDB/Raw/TpiStream.cpp @@ -103,7 +103,12 @@ Error TpiStream::reload() { // Hash indices, hash values, etc come from the hash stream. HashStream.reset(new MappedBlockStream(Header->HashStreamIndex, Pdb)); codeview::StreamReader HSR(*HashStream); + uint32_t NumHashValues = Header->HashValueBuffer.Length / sizeof(ulittle32_t); + if (NumHashValues != NumTypeRecords()) + return make_error( + raw_error_code::corrupt_file, + "TPI hash count does not match with the number of type records."); HSR.setOffset(Header->HashValueBuffer.Off); if (auto EC = HSR.readArray(HashValues, NumHashValues)) return EC;