From 5ffad4b00b2312d4ccd234e59953e570a83a7979 Mon Sep 17 00:00:00 2001 From: Jacky Liu Date: Wed, 29 Dec 2021 12:09:06 +0800 Subject: Fix wrong key indexes in package verification logs. If the verification fails with the key, 'continue' will be performed and the increment of the index at the end of the loop will be skipped. This CL fixes it. Test: check the log and see correct key indexes. Change-Id: I3d1b2b8b4189f5fedbf8828f5e8e0d0b2e277c6a --- otautil/verifier.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'otautil/verifier.cpp') diff --git a/otautil/verifier.cpp b/otautil/verifier.cpp index 92b9faf29..8a65566ec 100644 --- a/otautil/verifier.cpp +++ b/otautil/verifier.cpp @@ -257,8 +257,8 @@ int verify_file(VerifierInterface* package, const std::vector& keys // Check to make sure at least one of the keys matches the signature. Since any key can match, // we need to try each before determining a verification failure has happened. - size_t i = 0; - for (const auto& key : keys) { + for (size_t i = 0; i < keys.size(); i++) { + const auto& key = keys[i]; const uint8_t* hash; int hash_nid; switch (key.hash_len) { @@ -296,7 +296,6 @@ int verify_file(VerifierInterface* package, const std::vector& keys } else { LOG(INFO) << "Unknown key type " << key.key_type; } - i++; } if (need_sha1) { -- cgit v1.2.3