diff --git a/snapshot/win/pe_image_reader.cc b/snapshot/win/pe_image_reader.cc index 5ca53f2f2..35c9afe16 100644 --- a/snapshot/win/pe_image_reader.cc +++ b/snapshot/win/pe_image_reader.cc @@ -177,7 +177,8 @@ bool PEImageReader::DebugDirectoryInformation(UUID* uuid, continue; if (debug_directory.AddressOfRawData) { - if (debug_directory.SizeOfData < sizeof(CodeViewRecordPDB70)) { + if (debug_directory.SizeOfData < + offsetof(CodeViewRecordPDB70, pdb_name) + 1) { LOG(WARNING) << "CodeView debug entry of unexpected size in " << module_subrange_reader_.name(); continue; @@ -200,6 +201,12 @@ bool PEImageReader::DebugDirectoryInformation(UUID* uuid, continue; } + if (data[data.size() - 1] != '\0') { + LOG(WARNING) << "CodeView debug entry missing NUL-terminator in " + << module_subrange_reader_.name(); + continue; + } + CodeViewRecordPDB70* codeview = reinterpret_cast(data.data()); *uuid = codeview->uuid;