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

Unified Diff: update_attempter.cc

Issue 3962005: AU: Don't request data ranges beyond the end of the payload. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: Created 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: update_attempter.cc
diff --git a/update_attempter.cc b/update_attempter.cc
index 1e3bf5db730f252134479075dbd843ff44e61c5b..7c324755aa328e3c97f108c637ca086ed65572f8 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -535,12 +535,19 @@ void UpdateAttempter::SetupDownload() {
download_action_->http_fetcher());
MultiHttpFetcher<LibcurlHttpFetcher>::RangesVect ranges;
if (response_handler_action_->install_plan().is_resume) {
+ // Resuming an update so fetch the update manifest metadata first.
int64_t manifest_metadata_size = 0;
prefs_->GetInt64(kPrefsManifestMetadataSize, &manifest_metadata_size);
+ ranges.push_back(make_pair(0, manifest_metadata_size));
+ // If there're remaining unprocessed data blobs, fetch them. Be careful not
+ // to request data beyond the end of the payload to avoid 416 HTTP response
+ // error codes.
int64_t next_data_offset = 0;
prefs_->GetInt64(kPrefsUpdateStateNextDataOffset, &next_data_offset);
- ranges.push_back(make_pair(0, manifest_metadata_size));
- ranges.push_back(make_pair(manifest_metadata_size + next_data_offset, -1));
+ uint64_t resume_offset = manifest_metadata_size + next_data_offset;
+ if (resume_offset < response_handler_action_->install_plan().size) {
+ ranges.push_back(make_pair(resume_offset, -1));
+ }
} else {
ranges.push_back(make_pair(0, -1));
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698