mirror of
https://github.com/u-boot/u-boot.git
synced 2024-11-27 06:04:40 +08: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
@ -50,6 +50,12 @@ static int image_verify_header(unsigned char *ptr, int image_size,
|
||||
struct legacy_img_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
|
||||
* checksum field for checking - this can't be done
|
||||
|
Loading…
Reference in New Issue
Block a user