From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: jre@pengutronix.de, Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH] FIT: compare key name hint with streq_ptr for clarity
Date: Fri, 10 Oct 2025 07:49:33 +0200 [thread overview]
Message-ID: <20251010054939.3067504-1-a.fatoum@barebox.org> (raw)
When given a key name hint, we first attempt verification using the key
it describes and fall through to verifying with all other keys.
The code implementing this is not necessarily intuitive and strcmp()
makes it harder to understand.
As we check for NULL pointer anyway, let's use streq_ptr, which returns
true instead of 0 on equality.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
common/image-fit.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/common/image-fit.c b/common/image-fit.c
index 6b44a79e9d1c..3017ccb5048f 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -290,7 +290,8 @@ static int fit_check_signature(struct fit_handle *handle, struct device_node *si
for_each_public_key(key) {
fail_reason = "verification failed";
- if (key_name && !strcmp(key->key_name_hint, key_name))
+ /* Don't recheck with same key as before */
+ if (streq_ptr(key->key_name_hint, key_name))
continue;
ret = public_key_verify(key, sig_value, sig_len, hash, algo);
--
2.47.3
next reply other threads:[~2025-10-10 5:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-10 5:49 Ahmad Fatoum [this message]
2025-10-10 8:45 ` Marco Felsch
2025-10-20 13:30 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251010054939.3067504-1-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.org \
--cc=jre@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox