app: aboot: add check on DDR space available
Added a check on available ddr size before reading
boot image from flash.
FPIIM-676
Change-Id: I94d23eef1948f18d01017dfb9a17b39055224cf8
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index 0a98150..0f0db40 100755
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -1255,6 +1255,18 @@
dprintf(INFO, "Loading boot image (%d): start\n", imagesize_actual);
bs_set_timestamp(BS_KERNEL_LOAD_START);
+ if (UINT_MAX - page_size < imagesize_actual)
+ {
+ dprintf(CRITICAL,"Integer overflow detected in bootimage header fields %u %s\n", __LINE__,__func__);
+ return -1;
+ }
+
+ /*Check the availability of RAM before reading boot image + max signature length from flash*/
+ if (target_get_max_flash_size() < (imagesize_actual + page_size))
+ {
+ dprintf(CRITICAL, "bootimage size is greater than DDR can hold\n");
+ return -1;
+ }
/* Read image without signature */
if (flash_read(ptn, offset, (void *)image_addr, imagesize_actual))
{