[Sound-open-firmware] [[RFC PATCH] 1/3] rimage: don't add date to css if date is NULL.

Liam Girdwood liam.r.girdwood at linux.intel.com
Sat Jan 27 18:00:26 CET 2018


On Fri, 2018-01-26 at 16:29 +0800, xionghu.luo at linux.intel.com wrote:
> 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)

Can we print an error here.

> +		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);


More information about the Sound-open-firmware mailing list