From: Pali Rohár Date: Wed, 11 Aug 2021 08:14:15 +0000 (+0200) Subject: tools: kwbimage: Verify size of v0 image header X-Git-Url: http://git.dujemihanovic.xyz/login.html?a=commitdiff_plain;h=33a0af2d8041b027cfbf6ab23c93026339aff142;p=u-boot.git tools: kwbimage: Verify size of v0 image header Check that extended image header size is not larger than file size. Signed-off-by: Pali Rohár Reviewed-by: Stefan Roese --- diff --git a/tools/kwbimage.c b/tools/kwbimage.c index 542779ed48..4709c6d544 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -1670,6 +1670,9 @@ static int kwbimage_verify_header(unsigned char *ptr, int image_size, if (mhdr->ext & 0x1) { struct ext_hdr_v0 *ext_hdr; + if (header_size + sizeof(*ext_hdr) > image_size) + return -FDT_ERR_BADSTRUCTURE; + ext_hdr = (struct ext_hdr_v0 *) (ptr + sizeof(struct main_hdr_v0)); checksum = image_checksum8(ext_hdr,