]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
tools: kwboot: Fix checking image header version
authorPali Rohár <pali@kernel.org>
Fri, 23 Jul 2021 09:14:22 +0000 (11:14 +0200)
committerStefan Roese <sr@denx.de>
Sat, 31 Jul 2021 07:49:32 +0000 (09:49 +0200)
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 <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
tools/kwboot.c

index 1d32c1b7ad2b814fda5652128bc302a54155e4cb..7feeaa45a22da97fed413bdf8a67862708f8d849 100644 (file)
@@ -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;