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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "update_engine/update_attempter.h" 5 #include "update_engine/update_attempter.h"
6 6
7 // From 'man clock_gettime': feature test macro: _POSIX_C_SOURCE >= 199309L 7 // From 'man clock_gettime': feature test macro: _POSIX_C_SOURCE >= 199309L
8 #ifndef _POSIX_C_SOURCE 8 #ifndef _POSIX_C_SOURCE
9 #define _POSIX_C_SOURCE 199309L 9 #define _POSIX_C_SOURCE 199309L
10 #endif // _POSIX_C_SOURCE 10 #endif // _POSIX_C_SOURCE
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 } 528 }
529 prefs_->SetInt64(kPrefsDeltaUpdateFailures, ++delta_failures); 529 prefs_->SetInt64(kPrefsDeltaUpdateFailures, ++delta_failures);
530 } 530 }
531 531
532 void UpdateAttempter::SetupDownload() { 532 void UpdateAttempter::SetupDownload() {
533 MultiHttpFetcher<LibcurlHttpFetcher>* fetcher = 533 MultiHttpFetcher<LibcurlHttpFetcher>* fetcher =
534 dynamic_cast<MultiHttpFetcher<LibcurlHttpFetcher>*>( 534 dynamic_cast<MultiHttpFetcher<LibcurlHttpFetcher>*>(
535 download_action_->http_fetcher()); 535 download_action_->http_fetcher());
536 MultiHttpFetcher<LibcurlHttpFetcher>::RangesVect ranges; 536 MultiHttpFetcher<LibcurlHttpFetcher>::RangesVect ranges;
537 if (response_handler_action_->install_plan().is_resume) { 537 if (response_handler_action_->install_plan().is_resume) {
538 // Resuming an update so fetch the update manifest metadata first.
538 int64_t manifest_metadata_size = 0; 539 int64_t manifest_metadata_size = 0;
539 prefs_->GetInt64(kPrefsManifestMetadataSize, &manifest_metadata_size); 540 prefs_->GetInt64(kPrefsManifestMetadataSize, &manifest_metadata_size);
541 ranges.push_back(make_pair(0, manifest_metadata_size));
542 // If there're remaining unprocessed data blobs, fetch them. Be careful not
543 // to request data beyond the end of the payload to avoid 416 HTTP response
544 // error codes.
540 int64_t next_data_offset = 0; 545 int64_t next_data_offset = 0;
541 prefs_->GetInt64(kPrefsUpdateStateNextDataOffset, &next_data_offset); 546 prefs_->GetInt64(kPrefsUpdateStateNextDataOffset, &next_data_offset);
542 ranges.push_back(make_pair(0, manifest_metadata_size)); 547 uint64_t resume_offset = manifest_metadata_size + next_data_offset;
543 ranges.push_back(make_pair(manifest_metadata_size + next_data_offset, -1)); 548 if (resume_offset < response_handler_action_->install_plan().size) {
549 ranges.push_back(make_pair(resume_offset, -1));
550 }
544 } else { 551 } else {
545 ranges.push_back(make_pair(0, -1)); 552 ranges.push_back(make_pair(0, -1));
546 } 553 }
547 fetcher->set_ranges(ranges); 554 fetcher->set_ranges(ranges);
548 } 555 }
549 556
550 } // namespace chromeos_update_engine 557 } // namespace chromeos_update_engine
OLDNEW
« 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