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

Unified Diff: delta_performer.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.h ('k') | delta_performer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: delta_performer.cc
diff --git a/delta_performer.cc b/delta_performer.cc
index d1110158f5f33f287e8ac33798803a7d18cb72f2..5bb5d0a7a40e8be940b802b83a9edd1f38cf69f0 100644
--- a/delta_performer.cc
+++ b/delta_performer.cc
@@ -578,6 +578,28 @@ bool DeltaPerformer::VerifyAppliedUpdate(const string& path,
return true;
}
+bool DeltaPerformer::VerifySourcePartitions() {
+ LOG(INFO) << "Verifying source partitions.";
+ CHECK(manifest_valid_);
+ if (manifest_.has_old_kernel_info()) {
+ const PartitionInfo& info = manifest_.old_kernel_info();
+ TEST_AND_RETURN_FALSE(current_kernel_hash_ != NULL &&
+ current_kernel_hash_->size() == info.hash().size() &&
+ memcmp(current_kernel_hash_->data(),
+ info.hash().data(),
+ current_kernel_hash_->size()) == 0);
+ }
+ if (manifest_.has_old_rootfs_info()) {
+ const PartitionInfo& info = manifest_.old_rootfs_info();
+ TEST_AND_RETURN_FALSE(current_rootfs_hash_ != NULL &&
+ current_rootfs_hash_->size() == info.hash().size() &&
+ memcmp(current_rootfs_hash_->data(),
+ info.hash().data(),
+ current_rootfs_hash_->size()) == 0);
+ }
+ return true;
+}
+
void DeltaPerformer::DiscardBufferHeadBytes(size_t count) {
hash_calculator_.Update(&buffer_[0], count);
buffer_.erase(buffer_.begin(), buffer_.begin() + count);
@@ -661,6 +683,7 @@ bool DeltaPerformer::PrimeUpdateState() {
next_operation == kUpdateStateOperationInvalid ||
next_operation <= 0) {
// Initiating a new update, no more state needs to be initialized.
+ TEST_AND_RETURN_FALSE(VerifySourcePartitions());
return true;
}
next_operation_num_ = next_operation;
« no previous file with comments | « delta_performer.h ('k') | delta_performer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698