diff options
author | Pali Rohár <pali@kernel.org> | 2021-07-23 11:14:00 +0200 |
---|---|---|
committer | Stefan Roese <sr@denx.de> | 2021-07-31 09:49:31 +0200 |
commit | 4efbf1c3273788b83dd1f7646d26ce9950e4b4dc (patch) | |
tree | 183b2165aa7e17243a4c5ddf2bd057c988d084a0 /tools/kwbimage.c | |
parent | 501a54a29cc20ce7df70f290fa274b8e2ea9d6f4 (diff) | |
download | u-boot-4efbf1c3273788b83dd1f7646d26ce9950e4b4dc.tar.gz |
tools: kwbimage: Don't crash when binary file name does not contain '/'
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@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
Diffstat (limited to 'tools/kwbimage.c')
-rw-r--r-- | tools/kwbimage.c | 2 |
1 files changed, 1 insertions, 1 deletions
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); } |