From: Pali Rohár Date: Fri, 23 Jul 2021 09:14:15 +0000 (+0200) Subject: tools: dumpimage: Fix crashing when trying to extract data from kwbimage X-Git-Url: http://git.dujemihanovic.xyz/img/sics.gif?a=commitdiff_plain;h=a18ae18a59615b1e7ff82bcf2d5740e2adbf6165;p=u-boot.git tools: dumpimage: Fix crashing when trying to extract data from kwbimage Trying to call the following command causes NULL pointer dereference in strlen(): ./tools/dumpimage -T kwbimage -o /tmp/out u-boot-spl.kwb Fix it by checking whether params->imagename is non-NULL before calling strlen(). Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Reviewed-by: Stefan Roese --- diff --git a/tools/kwbimage.c b/tools/kwbimage.c index f3b16d94ad..5410df63f5 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -1867,7 +1867,7 @@ static int kwbimage_generate(struct image_tool_params *params, */ static int kwbimage_check_params(struct image_tool_params *params) { - if (!strlen(params->imagename)) { + if (!params->imagename || !strlen(params->imagename)) { char *msg = "Configuration file for kwbimage creation omitted"; fprintf(stderr, "Error:%s - %s\n", params->cmdname, msg);