From 7c1d426dbc4f5539929247027e4bd1c33ec63471 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Fri, 6 Jul 2018 23:18:14 -0700 Subject: applypatch: Restrict applypatch_check to eMMC targets. Also fix an error-pone behavior in previous code when verifying an eMMC target. As long as it loads the partition content successfully according to the SHAs embedded in the filename, it shouldn't further check against the SHAs given in the second argument. Because the loaded contents relate to a specific partition size. For example: apply_patch_check( "EMMC:/boot.img:src_size:src_hash:tgt_size:tgt_hash", "src_hash"); Assume "/boot.img" already has the desired hash of "tgt_hash", the previous code would give wrong verification result. The issue can be addressed by additionally listing "tgt_hash" as one of the desired SHAs (or by applying this CL). Bug: 110106408 Test: Run recovery_unit_test and recovery_component_test on marlin. Change-Id: I8daafdbecd083f687e24d563ab089caa25667633 --- tests/component/updater_test.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/component') diff --git a/tests/component/updater_test.cpp b/tests/component/updater_test.cpp index 0b6b96f7c..f50e861b0 100644 --- a/tests/component/updater_test.cpp +++ b/tests/component/updater_test.cpp @@ -250,8 +250,10 @@ TEST_F(UpdaterTest, apply_patch_check) { expect("t", cmd.c_str(), kNoCause); // Multiple arguments. + // As long as it successfully loads the partition specified in filename, it won't check against + // any given SHAs. cmd = "apply_patch_check(\"" + filename + "\", \"wrong_sha1\", \"wrong_sha2\")"; - expect("", cmd.c_str(), kNoCause); + expect("t", cmd.c_str(), kNoCause); cmd = "apply_patch_check(\"" + filename + "\", \"wrong_sha1\", \"" + src_hash + "\", \"wrong_sha2\")"; -- cgit v1.2.3