On Tue, Dec 16, 2014 at 01:04:05AM +1100, Jonathan Gray wrote:

> So now time is printed by default afl has found that time_t values
> such as -9223372035438150153 will cause localtime() to fail and
> return NULL.  strftime() can't deal with this and will at some point
> dereference tm without checking if it is NULL causing a crash.

I'd pefer to print the time_t value if it cannot be converted.

        -Otto

> Index: ktrstruct.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/kdump/ktrstruct.c,v
> retrieving revision 1.8
> diff -u -p -r1.8 ktrstruct.c
> --- ktrstruct.c       15 Dec 2014 01:48:54 -0000      1.8
> +++ ktrstruct.c       15 Dec 2014 13:56:03 -0000
> @@ -146,8 +146,10 @@ print_time(time_t t, int relative, int h
>  
>       if (!relative) {
>               tm = localtime(&t);
> -             (void)strftime(timestr, sizeof(timestr), TIME_FORMAT, tm);
> -             printf("<\"%s\">", timestr);
> +             if (tm != NULL) {
> +                     (void)strftime(timestr, sizeof(timestr), TIME_FORMAT, 
> tm);
> +                     printf("<\"%s\">", timestr);
> +             }
>       }
>  }
>  

Reply via email to