Re: NULL pointer dereference in tai64nlocal
Rick Myers <[email protected]> Thu, 12 Sep 2013 05:34:59 -0400
| Newsgroups | gmane.comp.djb.syslog |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Sep 11, 2013 at 05:41:19PM -0600, Andy Bradford wrote: > Thus said [email protected] on Tue, 10 Sep 2013 18:56:58 +1000: > > > # echo @ | tai64nlocal > > Segmentation fault > > Seems this is a problem that only happens on Linux: Apparently it's a signedness problem... typedef __time_t time_t; typedef __TIME_T_TYPE __time_t; #define __TIME_T_TYPE __SLONGWORD_TYPE #define __SLONGWORD_TYPE long int Which can be "fixed" with... --- tai64nlocal.c~ 2013-09-12 04:56:24.145298692 -0400 +++ tai64nlocal.c 2013-09-12 04:56:47.576278760 -0400 @@ -52,6 +52,7 @@ nanosecs += u; } secs -= 4611686018427387914ULL; + secs = secs > 0 ? secs : 0; t = localtime(&secs); out(num,fmt_ulong(num,1900 + t->tm_year)); out("-",1); out(num,fmt_uint0(num,1 + t->tm_mon,2)); Resulting in... $ echo @ | tai64nlocal 1969-12-31 19:00:00.000000000 -- New systems generate new problems.