mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-14 00:47:26 +00:00
tools: default_image: Verify header size
Before reading image header, verify that image size is at least size of the image header. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
afd82187b5
commit
3f837b06b7
1 changed files with 6 additions and 0 deletions
|
@ -50,6 +50,12 @@ static int image_verify_header(unsigned char *ptr, int image_size,
|
||||||
struct legacy_img_hdr header;
|
struct legacy_img_hdr header;
|
||||||
struct legacy_img_hdr *hdr = &header;
|
struct legacy_img_hdr *hdr = &header;
|
||||||
|
|
||||||
|
if (image_size < sizeof(struct legacy_img_hdr)) {
|
||||||
|
debug("%s: Bad image size: \"%s\" is no valid image\n",
|
||||||
|
params->cmdname, params->imagefile);
|
||||||
|
return -FDT_ERR_BADSTRUCTURE;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create copy of header so that we can blank out the
|
* create copy of header so that we can blank out the
|
||||||
* checksum field for checking - this can't be done
|
* checksum field for checking - this can't be done
|
||||||
|
|
Loading…
Reference in a new issue