From 61962b94f331c0ab2a21c9983f528169a25dce45 Mon Sep 17 00:00:00 2001 From: Roland Mikhel Date: Tue, 25 Apr 2023 14:03:08 +0200 Subject: [PATCH] bootutil: fix FIH int conversion for security_cnt Currently there's a compile error when building MCUboot with HW_ROLLBACK_PROT due to a comparison when decoding the security_cnt fih_int value. In the security_cnt.h it is stated that this value must be between 0 and UINT32_MAX so this cast would not cause any undefined behaviour. Signed-off-by: Roland Mikhel Change-Id: Iee158a31955ff43b73e67a0c08e7a086077b9eb5 --- boot/bootutil/src/image_validate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot/bootutil/src/image_validate.c b/boot/bootutil/src/image_validate.c index 699017aa..8260e594 100644 --- a/boot/bootutil/src/image_validate.c +++ b/boot/bootutil/src/image_validate.c @@ -494,7 +494,7 @@ bootutil_img_validate(struct enc_key_data *enc_state, int image_index, * stored security counter value. */ fih_rc = fih_ret_encode_zero_equality(img_security_cnt < - fih_int_decode(security_cnt)); + (uint32_t)fih_int_decode(security_cnt)); if (FIH_NOT_EQ(fih_rc, FIH_SUCCESS)) { FIH_SET(fih_rc, FIH_FAILURE); goto out;