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

Unified Diff: download_action.cc

Issue 3712003: AU: Verify source rootfs/kernel hashes before applying delta. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: verify source partitions only for new updates 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 | « delta_performer_unittest.cc ('k') | filesystem_copier_action.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: download_action.cc
diff --git a/download_action.cc b/download_action.cc
index 2920d16fd055503097f7d8695be389a44bd55c79..b6f7f81f14d17b8c036cab14ad68c2eeaa0ed992 100644
--- a/download_action.cc
+++ b/download_action.cc
@@ -64,6 +64,10 @@ void DownloadAction::PerformAction() {
writer_ = decompressing_file_writer_.get();
} else {
delta_performer_.reset(new DeltaPerformer(prefs_));
+ delta_performer_->set_current_kernel_hash(
+ &install_plan_.current_kernel_hash);
+ delta_performer_->set_current_rootfs_hash(
+ &install_plan_.current_rootfs_hash);
writer_ = delta_performer_.get();
}
}
@@ -93,9 +97,10 @@ void DownloadAction::PerformAction() {
}
void DownloadAction::TerminateProcessing() {
- CHECK(writer_);
- CHECK_EQ(writer_->Close(), 0);
- writer_ = NULL;
+ if (writer_) {
+ LOG_IF(WARNING, writer_->Close() != 0) << "Error closing the writer.";
+ writer_ = NULL;
+ }
http_fetcher_->TerminateTransfer();
if (delegate_) {
delegate_->SetDownloadStatus(false); // Set to inactive.
@@ -108,8 +113,12 @@ void DownloadAction::ReceivedBytes(HttpFetcher *fetcher,
bytes_received_ += length;
if (delegate_)
delegate_->BytesReceived(bytes_received_, install_plan_.size);
- int rc = writer_->Write(bytes, length);
- TEST_AND_RETURN(rc >= 0);
+ if (writer_ && writer_->Write(bytes, length) < 0) {
+ LOG(ERROR) << "Write error -- terminating processing.";
+ TerminateProcessing();
+ processor_->ActionComplete(this, kActionCodeDownloadWriteError);
+ return;
+ }
omaha_hash_calculator_.Update(bytes, length);
}
@@ -131,7 +140,7 @@ void FlushLinuxCaches() {
void DownloadAction::TransferComplete(HttpFetcher *fetcher, bool successful) {
if (writer_) {
- CHECK_EQ(writer_->Close(), 0) << errno;
+ LOG_IF(WARNING, writer_->Close() != 0) << "Error closing the writer.";
writer_ = NULL;
}
if (delegate_) {
« no previous file with comments | « delta_performer_unittest.cc ('k') | filesystem_copier_action.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698