From 252e7c3a24fefdf88dfa3fff87e8dc4d0c7aa9cc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pali=20Roh=C3=A1r?= Date: Wed, 12 Jan 2022 18:20:42 +0100 Subject: [PATCH] tools: kwbimage: Check the return value of image_headersz_v1() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Function image_headersz_v1() may return zero on fatal errors. In this case the function already printed an error message. Check the return value of image_headersz_v1() in kwbimage_generate(), and exit on zero value with EXIT_FAILURE. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese --- tools/kwbimage.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/kwbimage.c b/tools/kwbimage.c index c0f1bdac02..a5b518f60b 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -2029,6 +2029,10 @@ static int kwbimage_generate(struct image_tool_params *params, case 1: alloc_len = image_headersz_v1(NULL); + if (!alloc_len) { + free(image_cfg); + exit(EXIT_FAILURE); + } break; default: -- 2.34.1