[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "date", "uptime" core dumps on huge time stamps (+ "stat" fix)
From: |
Jim Meyering |
Subject: |
Re: "date", "uptime" core dumps on huge time stamps (+ "stat" fix) |
Date: |
Thu, 05 Feb 2004 10:53:02 +0100 |
Paul Eggert <address@hidden> wrote:
> I just notice that coreutils sometimes calls 'localtime' without
> checking that the result is not NULL, which can lead to core dumps on
> hosts with 64-bit time_t and 32-bit int (e.g., 64-bit Solaris). Here
> are some fixes.
>
> The "stat" patch doesn't fix a core dump on any host that I know
> about, but it's possible on far-future hosts and anyway the fix is
> easy. The stat.c patch also changes the behavior of stat to be nicer
> if stat is given time stamps that localtime can't convert.
>
> 2004-02-02 Paul Eggert <address@hidden>
>
> Don't dump core if localtime returns NULL (possible on
> hosts with 64-bit time_t and 32-bit int).
> * src/date.c: Include "inttostr.h".
> (batch_convert, main):
> If time conversion fails, exit with nonzero status.
> (show_date): Return int to report conversion failure.
> Print the time as an int if localtime fails.
> * src/uptime.c: Print "??" if the current clock can't
> be converted by localtime. This won't happen until the year
> 2*31 + 1900, but we don't want to dump core even if the current
> clock has the wrong value.
>
> * src/stat.c: Include "inttostr.h".
> (human_time): Print the date/time as a number of seconds since the
> epoch if it can't be converted by localtime. This is better than
> just saying "invalid", and is consistent with what "ls" does.
> Don't dump core if the year has more than 48 digits; this isn't
> possible on any contemporary host, but we might as well do it right.
Thank you!
I've merged those changes.