Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Unified Diff: snapshot/win/pe_image_reader.cc

Issue 1411123011: win: Don't attempt to read a nonexistent IMAGE_DIRECTORY_ENTRY_DEBUG (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« snapshot/win/pe_image_reader.h ('K') | « snapshot/win/pe_image_reader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: snapshot/win/pe_image_reader.cc
diff --git a/snapshot/win/pe_image_reader.cc b/snapshot/win/pe_image_reader.cc
index 7268358a056eaedd1091a76ca939ecac0e00db23..486bb6d4de236e8d335ab52e850cc2e08e42e8dc 100644
--- a/snapshot/win/pe_image_reader.cc
+++ b/snapshot/win/pe_image_reader.cc
@@ -143,10 +143,19 @@ template <class NtHeadersType>
bool PEImageReader::ReadDebugDirectoryInformation(UUID* uuid,
DWORD* age,
std::string* pdbname) const {
- WinVMAddress nt_headers_address;
NtHeadersType nt_headers;
- if (!ReadNtHeaders(&nt_headers_address, &nt_headers))
+ if (!ReadNtHeaders(nullptr, &nt_headers))
+ return false;
+
+ if (nt_headers.FileHeader.SizeOfOptionalHeader <
+ offsetof(decltype(nt_headers.OptionalHeader),
+ DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG]) +
+ sizeof(nt_headers.OptionalHeader
+ .DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG]) ||
+ nt_headers.OptionalHeader.NumberOfRvaAndSizes <=
+ IMAGE_DIRECTORY_ENTRY_DEBUG) {
return false;
+ }
const IMAGE_DATA_DIRECTORY& data_directory =
nt_headers.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG];
@@ -215,9 +224,9 @@ bool PEImageReader::ReadNtHeaders(WinVMAddress* nt_headers_address,
return false;
}
- *nt_headers_address = Address() + dos_header.e_lfanew;
+ WinVMAddress local_nt_headers_address = Address() + dos_header.e_lfanew;
if (!CheckedReadMemory(
- *nt_headers_address, sizeof(NtHeadersType), nt_headers)) {
+ local_nt_headers_address, sizeof(NtHeadersType), nt_headers)) {
LOG(WARNING) << "could not read nt headers of " << module_name_;
return false;
}
@@ -227,6 +236,9 @@ bool PEImageReader::ReadNtHeaders(WinVMAddress* nt_headers_address,
return false;
}
+ if (nt_headers_address)
+ *nt_headers_address = local_nt_headers_address;
+
return true;
}
« snapshot/win/pe_image_reader.h ('K') | « snapshot/win/pe_image_reader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698