[PATCH u-boot-mvebu v3 28/41] tools: kwboot: Fix checking image header version

Marek Behún marek.behun at nic.cz
Fri Jul 23 11:14:22 CEST 2021


From: Pali Rohár <pali at kernel.org>

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 at kernel.org>
Reviewed-by: Marek Behún <marek.behun at nic.cz>
Reviewed-by: Stefan Roese <sr at denx.de>
---
 tools/kwboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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;
-- 
2.31.1



More information about the U-Boot mailing list