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

Unified Diff: shell/application_manager/network_fetcher.cc

Issue 1009003002: Fix subtle dynamic library loading problem and deflake the tree. Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « shell/application_manager/network_fetcher.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: shell/application_manager/network_fetcher.cc
diff --git a/shell/application_manager/network_fetcher.cc b/shell/application_manager/network_fetcher.cc
index 05aba7ab3605b5837b5acdb53e789b03f50c0246..c1fa5fb248f7a11ee2c21a7e3f89298eed80dc85 100644
--- a/shell/application_manager/network_fetcher.cc
+++ b/shell/application_manager/network_fetcher.cc
@@ -87,7 +87,8 @@ void NetworkFetcher::RecordCacheToURLMapping(const base::FilePath& path,
// AppIds should be be both predictable and unique, but any hash would work.
// Currently we use sha256 from crypto/secure_hash.h
-bool NetworkFetcher::ComputeAppId(const base::FilePath& path,
+bool NetworkFetcher::ComputeAppId(const GURL& canonical_url,
+ const base::FilePath& path,
std::string* digest_string) {
scoped_ptr<crypto::SecureHash> ctx(
crypto::SecureHash::Create(crypto::SecureHash::SHA256));
@@ -96,6 +97,11 @@ bool NetworkFetcher::ComputeAppId(const base::FilePath& path,
LOG(ERROR) << "Failed to open " << path.value() << " for computing AppId";
return false;
}
+ std::string spec = canonical_url.spec();
+ uint32_t len = static_cast<uint32_t>(spec.size());
+ // Prevent URL vs. content spoofing.
+ ctx->Update(&len, sizeof(len));
+ ctx->Update(spec.c_str(), spec.size());
char buf[1024];
while (file.IsValid()) {
int bytes_read = file.ReadAtCurrentPos(buf, sizeof(buf));
@@ -116,10 +122,11 @@ bool NetworkFetcher::ComputeAppId(const base::FilePath& path,
return true;
}
-bool NetworkFetcher::RenameToAppId(const base::FilePath& old_path,
+bool NetworkFetcher::RenameToAppId(const GURL& canonical_url,
+ const base::FilePath& old_path,
base::FilePath* new_path) {
std::string app_id;
- if (!ComputeAppId(old_path, &app_id))
+ if (!ComputeAppId(canonical_url, old_path, &app_id))
return false;
base::FilePath temp_dir;
@@ -136,7 +143,7 @@ void NetworkFetcher::CopyCompleted(
if (success) {
success = false;
base::FilePath new_path;
- if (RenameToAppId(path_, &new_path)) {
+ if (RenameToAppId(GURL(response_->url), path_, &new_path)) {
if (base::PathExists(new_path)) {
path_ = new_path;
success = true;
« no previous file with comments | « shell/application_manager/network_fetcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698