From: Pali Rohár Date: Fri, 23 Jul 2021 09:14:22 +0000 (+0200) Subject: tools: kwboot: Fix checking image header version X-Git-Url: http://git.dujemihanovic.xyz/img/sics.gif?a=commitdiff_plain;h=5029d7bf34ec14730faa74d0fa1a229ec21233c9;p=u-boot.git tools: kwboot: Fix checking image header version Function image_version() returns unsigned value, so it can never be negative. Explicitly check for two supported image versions: v0 and v1. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese --- diff --git a/tools/kwboot.c b/tools/kwboot.c index 1d32c1b7ad..7feeaa45a2 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -634,7 +634,7 @@ kwboot_img_patch_hdr(void *img, size_t size) } image_ver = image_version(img); - if (image_ver < 0) { + if (image_ver != 0 && image_ver != 1) { fprintf(stderr, "Invalid image header version\n"); errno = EINVAL; goto out;