mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-06-21 06:01:39 +00:00
kwbimage: Fix out of bounds access
The kwbimage format is reading beyond its header structure if it misdetects a Xilinx Zynq image and tries to read it. Fix it by sanity checking that the header we want to read fits inside our file size. Signed-off-by: Alexander Graf <agraf@suse.de> Tested-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Stefan Roese <sr@denx.de> Signed-off-by: Stefan Roese <sr@denx.de>
This commit is contained in:
parent
bc8cb152d8
commit
6cd5678c45
1 changed files with 4 additions and 0 deletions
|
@ -1616,6 +1616,10 @@ static int kwbimage_verify_header(unsigned char *ptr, int image_size,
|
||||||
struct image_tool_params *params)
|
struct image_tool_params *params)
|
||||||
{
|
{
|
||||||
uint8_t checksum;
|
uint8_t checksum;
|
||||||
|
size_t header_size = kwbimage_header_size(ptr);
|
||||||
|
|
||||||
|
if (header_size > image_size)
|
||||||
|
return -FDT_ERR_BADSTRUCTURE;
|
||||||
|
|
||||||
if (!main_hdr_checksum_ok(ptr))
|
if (!main_hdr_checksum_ok(ptr))
|
||||||
return -FDT_ERR_BADSTRUCTURE;
|
return -FDT_ERR_BADSTRUCTURE;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue