Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Fix inclusion of archived binaries in client download requests
Browse files Browse the repository at this point in the history
BUG=475925
[email protected]

Review URL: https://codereview.chromium.org/1076243002

Cr-Commit-Position: refs/heads/master@{#324725}
(cherry picked from commit f0710b9)
[email protected]

Review URL: https://codereview.chromium.org/1083523004

Cr-Commit-Position: refs/branch-heads/2357@{#51}
Cr-Branched-From: 59d4494-refs/heads/master@{#323860}
  • Loading branch information
GregTho committed Apr 12, 2015
1 parent d8b5a1d commit 46629f9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions chrome/browser/safe_browsing/download_protection_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -771,12 +771,12 @@ class DownloadProtectionService::CheckClientDownloadRequest
request.mutable_signature()->CopyFrom(signature_info_);
if (image_headers_)
request.set_allocated_image_headers(image_headers_.release());
if (zipped_executable_)
request.mutable_archived_binary()->Swap(&archived_binary_);
if (!request.SerializeToString(&client_download_request_data_)) {
FinishRequest(UNKNOWN, REASON_INVALID_REQUEST_PROTO);
return;
}
if (zipped_executable_)
request.mutable_archived_binary()->Swap(&archived_binary_);
service_->client_download_request_callbacks_.Notify(item_, &request);

DVLOG(2) << "Sending a request for URL: "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "chrome/browser/safe_browsing/download_protection_service.h"

#include <stdint.h>
#include <map>
#include <string>

Expand Down Expand Up @@ -279,6 +280,16 @@ class DownloadProtectionServiceTest : public testing::Test {
return false;
}

static const ClientDownloadRequest_ArchivedBinary* GetRequestArchivedBinary(
const ClientDownloadRequest& request,
const std::string& file_basename) {
for (const auto& archived_binary : request.archived_binary()) {
if (archived_binary.file_basename() == file_basename)
return &archived_binary;
}
return nullptr;
}

// Flushes any pending tasks in the message loops of all threads.
void FlushThreadMessageLoops() {
BrowserThread::GetBlockingPool()->FlushForTesting();
Expand Down Expand Up @@ -1113,6 +1124,15 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadZip) {
#if defined(OS_WIN) || defined(OS_MACOSX)
// OSX sends pings for evaluation purposes.
EXPECT_TRUE(HasClientDownloadRequest());
const ClientDownloadRequest& request = *GetClientDownloadRequest();
EXPECT_EQ(1, request.archived_binary_size());
const ClientDownloadRequest_ArchivedBinary* archived_binary =
GetRequestArchivedBinary(request, "file.exe");
ASSERT_NE(nullptr, archived_binary);
EXPECT_EQ(ClientDownloadRequest_DownloadType_WIN_EXECUTABLE,
archived_binary->download_type());
EXPECT_EQ(static_cast<int64_t>(file_contents.size()),
archived_binary->length());
ClearClientDownloadRequest();
#else
EXPECT_FALSE(HasClientDownloadRequest());
Expand Down

0 comments on commit 46629f9

Please sign in to comment.