[PATCH u-boot-mvebu v3 06/41] tools: kwbimage: Don't crash when binary file name does not contain '/'
Marek Behún
marek.behun at nic.cz
Fri Jul 23 11:14:00 CEST 2021
From: Pali Rohár <pali at kernel.org>
In the case when the file name is specified relative to the current
working directory, it does not contain '/' character and strrchr()
returns NULL.
The following strcmp() function then crashes on NULL pointer
dereference.
Signed-off-by: Pali Rohár <pali at kernel.org>
Reviewed-by: Marek Behún <marek.behun at nic.cz>
Reviewed-by: Stefan Roese <sr at denx.de>
Reviewed-by: Chris Packham <judge.packham at gmail.com>
Tested-by: Chris Packham <judge.packham at gmail.com>
---
tools/kwbimage.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/kwbimage.c b/tools/kwbimage.c
index c65a40ecb7..724459fb8e 100644
--- a/tools/kwbimage.c
+++ b/tools/kwbimage.c
@@ -1277,7 +1277,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,
if (e) {
char *s = strrchr(e->binary.file, '/');
- if (strcmp(s, "/binary.0") == 0)
+ if (s && strcmp(s, "/binary.0") == 0)
main_hdr->destaddr = cpu_to_le32(params->addr);
}
--
2.31.1
More information about the U-Boot
mailing list