[PATCH u-boot-marvell v2 09/20] tools: kwbimage: Check for maximal kwbimage header size

Pali Rohár
2022-01-12T17:23:32Z

BootROM loads kwbimage header to L2-SRAM and BootROM reserve only 192 kB for it.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
tools/kwbimage.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/tools/kwbimage.c b/tools/kwbimage.c
index a5b518f60bc8..ce053a4a5a78 100644
--- a/tools/kwbimage.c
+++ b/tools/kwbimage.c
@@ -2033,6 +2033,11 @@ static int kwbimage_generate(struct image_tool_params *params,
free(image_cfg);
exit(EXIT_FAILURE);
}
+ if (alloc_len > 192*1024) {
+ fprintf(stderr, "Header is too big (%u bytes), maximal kwbimage header size is %u bytes\n", alloc_len, 192*1024);
+ free(image_cfg);
+ exit(EXIT_FAILURE);
+ }
break;

default:
--
2.20.1