[PATCH 2/4] tools: kwbimage: Verify size of v0 image header
Stefan Roese
sr at denx.de
Wed Aug 11 16:18:45 CEST 2021
On 11.08.21 10:14, Pali Rohár wrote:
> Check that extended image header size is not larger than file size.
>
> Signed-off-by: Pali Rohár <pali at kernel.org>
Reviewed-by: Stefan Roese <sr at denx.de>
Thanks,
Stefan
> ---
> tools/kwbimage.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/tools/kwbimage.c b/tools/kwbimage.c
> index 80aae8a6b619..84c41210e39e 100644
> --- a/tools/kwbimage.c
> +++ b/tools/kwbimage.c
> @@ -1682,6 +1682,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,
>
Viele Grüße,
Stefan
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
More information about the U-Boot
mailing list