summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMarek BehĂșn <marek.behun@nic.cz>2021-09-24 23:07:04 +0200
committerStefan Roese <sr@denx.de>2021-10-01 11:07:13 +0200
commit5c8f812ca93731f5177559db9f491f7bfeb0188d (patch)
tree2c99f6d5eafe7118d0dfe0edb7b091f37ef2355a /tools
parent04ced0296e66ff0fbeafbbf2e94d2441237f49c8 (diff)
downloadu-boot-5c8f812ca93731f5177559db9f491f7bfeb0188d.tar.gz
u-boot-5c8f812ca93731f5177559db9f491f7bfeb0188d.tar.bz2
u-boot-5c8f812ca93731f5177559db9f491f7bfeb0188d.zip
tools: kwboot: Explicitly check against size of struct main_hdr_v1
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 <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'tools')
-rw-r--r--tools/kwboot.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/kwboot.c b/tools/kwboot.c
index 4fae44c46e..77bf5cb80b 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;
}