summaryrefslogtreecommitdiff
path: root/payload_consumer/filesystem_verifier_action.cc
diff options
context:
space:
mode:
authorSen Jiang <senj@google.com>2016-05-25 11:08:41 -0700
committerSen Jiang <senj@google.com>2016-06-06 23:54:17 +0000
commita35896c0ab209488b347672e9c917355b3fd8f51 (patch)
tree6514e5569b04b71ec3ef77cc596a4060d25f9abf /payload_consumer/filesystem_verifier_action.cc
parent192a86a7e3b5ec90d7860f817100be6a43ca1daa (diff)
Only verify the source partition which target hash mismatch.
There's no need to go back to the first partition when target partition hash failed, those partitions already passed target hash verification. We should directly go ahead and verify the source partition corresponding to the current partition which target hash doesn't match, and that should be the only source partition we verify. Test: ./update_engine_unittests Bug: None Change-Id: I6754d329d62fbed214e2b01568b290a60ad746ac
Diffstat (limited to 'payload_consumer/filesystem_verifier_action.cc')
-rw-r--r--payload_consumer/filesystem_verifier_action.cc23
1 files changed, 8 insertions, 15 deletions
diff --git a/payload_consumer/filesystem_verifier_action.cc b/payload_consumer/filesystem_verifier_action.cc
index 4b476dbd..5156f966 100644
--- a/payload_consumer/filesystem_verifier_action.cc
+++ b/payload_consumer/filesystem_verifier_action.cc
@@ -91,18 +91,7 @@ void FilesystemVerifierAction::Cleanup(ErrorCode code) {
void FilesystemVerifierAction::StartPartitionHashing() {
if (partition_index_ == install_plan_.partitions.size()) {
- switch (verifier_step_) {
- case VerifierStep::kVerifySourceHash:
- // The action will skip kVerifySourceHash step if target partition hash
- // matches, if we are in this step, it means target hash does not match,
- // and now that the source hash matches, we should set the error code to
- // reflect the error in target partition.
- Cleanup(ErrorCode::kNewRootfsVerificationError);
- break;
- case VerifierStep::kVerifyTargetHash:
- Cleanup(ErrorCode::kSuccess);
- break;
- }
+ Cleanup(ErrorCode::kSuccess);
return;
}
InstallPlan::Partition& partition =
@@ -224,7 +213,6 @@ void FilesystemVerifierAction::FinishPartitionHashing() {
// switch to kVerifySourceHash step to check if it's because the source
// partition does not match either.
verifier_step_ = VerifierStep::kVerifySourceHash;
- partition_index_ = 0;
} else {
partition_index_++;
}
@@ -256,8 +244,13 @@ void FilesystemVerifierAction::FinishPartitionHashing() {
<< "run: .../src/scripts/sha256_partitions.sh .../file.bin";
return Cleanup(ErrorCode::kDownloadStateInitializationError);
}
- partition_index_++;
- break;
+ // The action will skip kVerifySourceHash step if target partition hash
+ // matches, if we are in this step, it means target hash does not match,
+ // and now that the source partition hash matches, we should set the error
+ // code to reflect the error in target partition.
+ // We only need to verify the source partition which the target hash does
+ // not match, the rest of the partitions don't matter.
+ return Cleanup(ErrorCode::kNewRootfsVerificationError);
}
// Start hashing the next partition, if any.
hasher_.reset();