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
This commit is contained in:
@@ -78,9 +78,10 @@ int applypatch(const char* source_filename, const char* target_filename,
|
||||
const std::vector<std::string>& patch_sha1s,
|
||||
const std::vector<std::unique_ptr<Value>>& patch_data, const Value* bonus_data);
|
||||
|
||||
// Returns 0 if the contents of the file or the cached file match any of the given SHA-1's. Returns
|
||||
// nonzero otherwise.
|
||||
int applypatch_check(const char* filename, const std::vector<std::string>& patch_sha1s);
|
||||
// Returns 0 if the contents of the eMMC target or the cached file match any of the given SHA-1's.
|
||||
// Returns nonzero otherwise. 'filename' must refer to an eMMC partition target. It would only use
|
||||
// 'sha1s' to find a match on /cache if the hashes embedded in the filename fail to match.
|
||||
int applypatch_check(const std::string& filename, const std::vector<std::string>& sha1s);
|
||||
|
||||
// Flashes a given image to the target partition. It verifies the target cheksum first, and will
|
||||
// return if target already has the desired hash. Otherwise it checks the checksum of the given
|
||||
|
||||
Reference in New Issue
Block a user