mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-02 09:46:37 +03: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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user