tool: ifwitool: The function localtime() can return NULL.
PATCH 1/1 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.
--- tools/ifwitool.c | 2 ++ 1 file changed, 2 insertions(+)
tools/ifwitool.c +2 -0
@@ -1630,6 +1630,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 );
Signature · 1 line
2.17.1
Quoted 6 lines · Mikhail Ilin
This will cause the
local_timepointer is passed as the 4th argument to functionstrftime()to also point to NULL. This result in a segmentation fault. Thus, it's necessary to add a check of thelocal_timepointer to NULL.
Quoted 6 lines
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by Mikhail Ilin <[email protected]>--- tools/ifwitool.c | 2 ++ 1 file changed, 2 insertions(+)
Quoted 9 lines · Mikhail Ilin
This will cause the
local_timepointer is passed as the 4th argument
to functionstrftime()to also point to NULL. This result in a segmentation fault. Thus, it's necessary to add a check of thelocal_timepointer to NULL.Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by Mikhail Ilin <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/next, thanks!
Signature · 1 line
Tom