diff options
author | grt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-26 21:51:30 +0000 |
---|---|---|
committer | grt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-26 21:51:30 +0000 |
commit | 497828478225c7ad7ed887cea4d5c7facf8340c1 (patch) | |
tree | 543f44ddbc7ffffe9bb14e93c3a770ea4c54f53d /chrome/browser/safe_browsing | |
parent | be42e94eac7971be0419d7d94f8c73297969911d (diff) | |
download | chromium_src-497828478225c7ad7ed887cea4d5c7facf8340c1.zip chromium_src-497828478225c7ad7ed887cea4d5c7facf8340c1.tar.gz chromium_src-497828478225c7ad7ed887cea4d5c7facf8340c1.tar.bz2 |
Fix crash when populating pb for images with debug data.
BUG=356730
NOTRY=true
R=mattm@chromium.org
Review URL: https://codereview.chromium.org/213333003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259703 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/safe_browsing')
-rw-r--r-- | chrome/browser/safe_browsing/binary_feature_extractor_win.cc | 2 | ||||
-rw-r--r-- | chrome/browser/safe_browsing/binary_feature_extractor_win_unittest.cc | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/chrome/browser/safe_browsing/binary_feature_extractor_win.cc b/chrome/browser/safe_browsing/binary_feature_extractor_win.cc index 74fcc44..76d8ed9 100644 --- a/chrome/browser/safe_browsing/binary_feature_extractor_win.cc +++ b/chrome/browser/safe_browsing/binary_feature_extractor_win.cc @@ -135,7 +135,7 @@ void BinaryFeatureExtractor::ExtractImageHeaders( pe_image.GetDebugEntry(i, &raw_data, &raw_data_size); if (directory_entry) { ClientDownloadRequest_PEImageHeaders_DebugData* debug_data = - pe_headers->mutable_debug_data(i); + pe_headers->add_debug_data(); debug_data->set_directory_entry(directory_entry, sizeof(*directory_entry)); if (raw_data) diff --git a/chrome/browser/safe_browsing/binary_feature_extractor_win_unittest.cc b/chrome/browser/safe_browsing/binary_feature_extractor_win_unittest.cc index 1d63bf2..10481da 100644 --- a/chrome/browser/safe_browsing/binary_feature_extractor_win_unittest.cc +++ b/chrome/browser/safe_browsing/binary_feature_extractor_win_unittest.cc @@ -140,4 +140,22 @@ TEST_F(BinaryFeatureExtractorWinTest, ExtractImageHeaders) { EXPECT_EQ(0, pe_headers.debug_data_size()); } +TEST_F(BinaryFeatureExtractorWinTest, ExtractImageHeadersWithDebugData) { + // Test extracting headers from something that is a PE image with debug data. + ClientDownloadRequest_ImageHeaders image_headers; + binary_feature_extractor_->ExtractImageHeaders( + testdata_path_.DirName().AppendASCII("module_with_exports_x86.dll"), + &image_headers); + EXPECT_TRUE(image_headers.has_pe_headers()); + const ClientDownloadRequest_PEImageHeaders& pe_headers = + image_headers.pe_headers(); + EXPECT_TRUE(pe_headers.has_dos_header()); + EXPECT_TRUE(pe_headers.has_file_header()); + EXPECT_TRUE(pe_headers.has_optional_headers32()); + EXPECT_FALSE(pe_headers.has_optional_headers64()); + EXPECT_NE(0, pe_headers.section_header_size()); + EXPECT_TRUE(pe_headers.has_export_section_data()); + EXPECT_EQ(1U, pe_headers.debug_data_size()); +} + } // namespace safe_browsing |