[Sound-open-firmware] [[RFC PATCH] 1/3] rimage: don't add date to css if date is NULL.
xionghu.luo at linux.intel.com
xionghu.luo at linux.intel.com
Fri Jan 26 09:29:36 CET 2018
From: Luo Xionghu <xionghu.luo at intel.com>
Avoid NULL dereference if function localtime return invalid value.
Signed-off-by: Luo Xionghu <xionghu.luo at intel.com>
---
rimage/css.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/rimage/css.c b/rimage/css.c
index f662f0b..064a75a 100644
--- a/rimage/css.c
+++ b/rimage/css.c
@@ -33,6 +33,9 @@ void ri_css_hdr_create(struct image *image)
/* get local time and date */
gettimeofday(&tv, NULL);
date = localtime(&tv.tv_sec);
+ if (date == NULL)
+ return;
+
date->tm_year += 1900;
fprintf(stdout, " css: set build date to %d:%2.2d:%2.2d\n",
date->tm_year, date->tm_mon, date->tm_mday);
--
2.11.0
More information about the Sound-open-firmware
mailing list