From e8212dd2eca368639abdfcd2f7e5bc47434ec5e5 Mon Sep 17 00:00:00 2001 From: Mattia Moffa Date: Wed, 6 May 2026 03:29:47 +0200 Subject: [PATCH] Check TLV fields' size is correct in image headers F#3540 --- src/libwolfboot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libwolfboot.c b/src/libwolfboot.c index 3b9f92b6..fed32052 100644 --- a/src/libwolfboot.c +++ b/src/libwolfboot.c @@ -1136,7 +1136,7 @@ uint32_t wolfBoot_get_blob_version(uint8_t *blob) if (*magic != WOLFBOOT_MAGIC) return 0; if (wolfBoot_find_header(img_bin + IMAGE_HEADER_OFFSET, HDR_VERSION, - (void *)&version_field) == 0) + (void *)&version_field) != sizeof(uint32_t)) return 0; if (version_field) return im2n(*version_field); @@ -1169,7 +1169,7 @@ uint16_t wolfBoot_get_blob_type(uint8_t *blob) if (*magic != WOLFBOOT_MAGIC) return 0; if (wolfBoot_find_header(img_bin + IMAGE_HEADER_OFFSET, HDR_IMG_TYPE, - (void *)&type_field) == 0) + (void *)&type_field) != sizeof(uint16_t)) return 0; if (type_field) return im2ns(*type_field); @@ -1206,7 +1206,7 @@ uint32_t wolfBoot_get_blob_diffbase_version(uint8_t *blob) if (*magic != WOLFBOOT_MAGIC) return 0; if (wolfBoot_find_header(img_bin + IMAGE_HEADER_OFFSET, HDR_IMG_DELTA_BASE, - (void *)&delta_base) == 0) + (void *)&delta_base) != sizeof(uint32_t)) return 0; if (delta_base) return im2n(*delta_base);