mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] fixup! FIT: compare key name hint with streq_ptr for clarity
@ 2025-10-22  9:38 Ahmad Fatoum
  2025-10-22  9:56 ` Sascha Hauer
  2025-10-22  9:57 ` Marco Felsch
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2025-10-22  9:38 UTC (permalink / raw)
  To: barebox; +Cc: Marco Felsch, Jonas Rebmann, Ahmad Fatoum

FIT: fix use of multiple FIT keys

streq_ptr returns true if both arguments are NULL. This can happen if we
have no FIT key name hints at all and shouldn't lead to ignoring keys,
so add the check for the hint.

Cc: Marco Felsch <m.felsch@pengutronix.de>
Reported-by: Jonas Rebmann <jre@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/image-fit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index 3017ccb5048f..22f768e7a070 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -290,8 +290,8 @@ static int fit_check_signature(struct fit_handle *handle, struct device_node *si
 	for_each_public_key(key) {
 		fail_reason = "verification failed";
 
-		/* Don't recheck with same key as before */
-		if (streq_ptr(key->key_name_hint, key_name))
+		/* Don't recheck with same key_name as before */
+		if (key_name && streq_ptr(key->key_name_hint, key_name))
 			continue;
 
 		ret = public_key_verify(key, sig_value, sig_len, hash, algo);
-- 
2.47.3




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fixup! FIT: compare key name hint with streq_ptr for clarity
  2025-10-22  9:38 [PATCH] fixup! FIT: compare key name hint with streq_ptr for clarity Ahmad Fatoum
@ 2025-10-22  9:56 ` Sascha Hauer
  2025-10-22  9:57 ` Marco Felsch
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2025-10-22  9:56 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox, Marco Felsch, Jonas Rebmann

On Wed, Oct 22, 2025 at 11:38:06AM +0200, Ahmad Fatoum wrote:
> FIT: fix use of multiple FIT keys
> 
> streq_ptr returns true if both arguments are NULL. This can happen if we
> have no FIT key name hints at all and shouldn't lead to ignoring keys,
> so add the check for the hint.

key_name_hint can't be NULL, so this is not necessary. However, it's not
exactly obvious that key_name_hint can't be NULL, so this fixup improves
readability, hence: applied.

Sascha

> index 3017ccb5048f..22f768e7a070 100644
> --- a/common/image-fit.c
> +++ b/common/image-fit.c
> @@ -290,8 +290,8 @@ static int fit_check_signature(struct fit_handle *handle, struct device_node *si
>  	for_each_public_key(key) {
>  		fail_reason = "verification failed";
>  
> -		/* Don't recheck with same key as before */
> -		if (streq_ptr(key->key_name_hint, key_name))
> +		/* Don't recheck with same key_name as before */
> +		if (key_name && streq_ptr(key->key_name_hint, key_name))
>  			continue;
>  
>  		ret = public_key_verify(key, sig_value, sig_len, hash, algo);
> -- 
> 2.47.3
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fixup! FIT: compare key name hint with streq_ptr for clarity
  2025-10-22  9:38 [PATCH] fixup! FIT: compare key name hint with streq_ptr for clarity Ahmad Fatoum
  2025-10-22  9:56 ` Sascha Hauer
@ 2025-10-22  9:57 ` Marco Felsch
  1 sibling, 0 replies; 3+ messages in thread
From: Marco Felsch @ 2025-10-22  9:57 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox, Jonas Rebmann

On 25-10-22, Ahmad Fatoum wrote:
> FIT: fix use of multiple FIT keys
> 
> streq_ptr returns true if both arguments are NULL. This can happen if we

Damn!

> have no FIT key name hints at all and shouldn't lead to ignoring keys,
> so add the check for the hint.
> 
> Cc: Marco Felsch <m.felsch@pengutronix.de>
> Reported-by: Jonas Rebmann <jre@pengutronix.de>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>

> ---
>  common/image-fit.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/common/image-fit.c b/common/image-fit.c
> index 3017ccb5048f..22f768e7a070 100644
> --- a/common/image-fit.c
> +++ b/common/image-fit.c
> @@ -290,8 +290,8 @@ static int fit_check_signature(struct fit_handle *handle, struct device_node *si
>  	for_each_public_key(key) {
>  		fail_reason = "verification failed";
>  
> -		/* Don't recheck with same key as before */
> -		if (streq_ptr(key->key_name_hint, key_name))
> +		/* Don't recheck with same key_name as before */
> +		if (key_name && streq_ptr(key->key_name_hint, key_name))
>  			continue;
>  
>  		ret = public_key_verify(key, sig_value, sig_len, hash, algo);
> -- 
> 2.47.3
> 
> 

-- 
#gernperDu 
#CallMeByMyFirstName

Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | https://www.pengutronix.de/ |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-9    |



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-10-22  9:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-22  9:38 [PATCH] fixup! FIT: compare key name hint with streq_ptr for clarity Ahmad Fatoum
2025-10-22  9:56 ` Sascha Hauer
2025-10-22  9:57 ` Marco Felsch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox