Re: [hackers] [sbase] ls: fix segfault when timestamp is negative

From: Mattias Andrée <maandree_AT_kth.se>
Date: Sun, 27 Mar 2016 16:06:23 +0200

On Sun, 27 Mar 2016 14:30:35 +0100
Connor Lane Smith <cls_AT_lubutu.com> wrote:

> On 27 March 2016 at 14:20, Mattias Andrée
> <maandree_AT_kth.se> wrote:
> > The timestamp happened to be negative
> > which caused strftime (glibc) in ls to segfault.
>
> I can't reproduce this with negative timestamps for
> strftime on glibc. It would also be a bug on their end,
> as far as I'm concerned.
>
> cls
>

The problem occur when tv_sec < -67768040609745132L.
It is not a bug in glibc. What happens is that tm_year
would overflow and therefore localtime returns NULL.

However, in musl this problem occur already at
tv_sec < -67768040604561132L, 2 months = 60 days
before the overflow happens.

Of course, overflow can also occur on large positive.
times. This overflow happens when tv_sec > 67768036191673199L.
Both glibc and musl support tv_sec = 67768036191673199L.

I think the best solution would be check whether localtime
returns NULL.

Received on Sun Mar 27 2016 - 16:06:23 CEST

This archive was generated by hypermail 2.3.0 : Sun Mar 27 2016 - 16:12:14 CEST