From 5c8f812ca93731f5177559db9f491f7bfeb0188d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Beh=C3=BAn?= Date: Fri, 24 Sep 2021 23:07:04 +0200 Subject: tools: kwboot: Explicitly check against size of struct main_hdr_v1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Explicitly check the image size against size of struct main_hdr_v1. This way the check is more readable, since the `hdrsz` variable may semantically contain another value. Signed-off-by: Marek BehĂșn Reviewed-by: Stefan Roese --- tools/kwboot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools/kwboot.c') diff --git a/tools/kwboot.c b/tools/kwboot.c index 4fae44c..77bf5cb 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -820,14 +820,14 @@ kwboot_img_patch_hdr(void *img, size_t *size) struct main_hdr_v1 *hdr; uint32_t srcaddr; uint8_t csum; - size_t hdrsz = sizeof(*hdr); + size_t hdrsz; int image_ver; int is_secure; rc = -1; hdr = img; - if (*size < hdrsz) { + if (*size < sizeof(struct main_hdr_v1)) { errno = EINVAL; goto out; } -- cgit v1.1