[PATCH 1/4] tools: kwbimage: Verify supported image version
Stefan Roese
sr at denx.de
Wed Aug 11 16:18:20 CEST 2021
On 11.08.21 10:14, Pali Rohár wrote:
> Only image versions 0 and 1 are supported. Verify it in
> kwbimage_verify_header() function.
>
> Signed-off-by: Pali Rohár <pali at kernel.org>
Reviewed-by: Stefan Roese <sr at denx.de>
Thanks,
Stefan
> ---
> tools/kwbimage.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tools/kwbimage.c b/tools/kwbimage.c
> index 4bff02bb3fb5..80aae8a6b619 100644
> --- a/tools/kwbimage.c
> +++ b/tools/kwbimage.c
> @@ -1690,9 +1690,7 @@ static int kwbimage_verify_header(unsigned char *ptr, int image_size,
> if (checksum != ext_hdr->checksum)
> return -FDT_ERR_BADSTRUCTURE;
> }
> - }
> -
> - if (image_version((void *)ptr) == 1) {
> + } else if (image_version((void *)ptr) == 1) {
> struct main_hdr_v1 *mhdr = (struct main_hdr_v1 *)ptr;
> uint32_t offset;
> uint32_t size;
> @@ -1762,6 +1760,8 @@ static int kwbimage_verify_header(unsigned char *ptr, int image_size,
> if (image_checksum32(ptr + offset, size - 4) !=
> *(uint32_t *)(ptr + offset + size - 4))
> return -FDT_ERR_BADSTRUCTURE;
> + } else {
> + return -FDT_ERR_BADSTRUCTURE;
> }
>
> return 0;
>
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