From: Mikhail Ilin Date: Fri, 18 Nov 2022 08:50:02 +0000 (+0300) Subject: tool: ifwitool: The function localtime() can return NULL. X-Git-Tag: v2023.07~207^2~11^2~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=164232943c77409921f0d1add63d1e41f0460715;p=platform%2Fkernel%2Fu-boot.git 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 Reviewed-by: Simon Glass --- diff --git a/tools/ifwitool.c b/tools/ifwitool.c index b2b06cc..a06eb7f 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);