summaryrefslogtreecommitdiff
path: root/tools/ifwitool.c
diff options
context:
space:
mode:
authorMikhail Ilin <[email protected]>2022-11-18 11:50:02 +0300
committerTom Rini <[email protected]>2022-12-08 09:25:44 -0500
commit164232943c77409921f0d1add63d1e41f0460715 (patch)
tree529df4fc2a03552f12605531db462ff6f9fde2de /tools/ifwitool.c
parentc059a22b7776dc4306acb73cbeb78e841cf60b84 (diff)
tool: ifwitool: The function localtime() can return NULL.
This will cause the local_time pointer is passed as the 4th argument to function strftime() to also point to NULL. This result in a segmentation fault. Thus, it's necessary to add a check of the local_time pointer to NULL. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Mikhail Ilin <[email protected]> Reviewed-by: Simon Glass <[email protected]>
Diffstat (limited to 'tools/ifwitool.c')
-rw-r--r--tools/ifwitool.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/ifwitool.c b/tools/ifwitool.c
index b2b06cc9219..a06eb7f33da 100644
--- a/tools/ifwitool.c
+++ b/tools/ifwitool.c
@@ -1628,6 +1628,8 @@ static void init_manifest_header(struct manifest_header *hdr, size_t size)
curr_time = time(NULL);
local_time = localtime(&curr_time);
+ assert(local_time != NULL);
+
strftime(buffer, sizeof(buffer), "0x%Y%m%d", local_time);
hdr->date = strtoul(buffer, NULL, 16);