Menu

#25 don't assume localtime() returns successfully

None
closed-fixed
nobody
None
5
2018-04-05
2007-07-23
Anonymous
No

localtime() can return NULL. When it does, strace dereferences its result anyway. Segfault ahoy!

Just try
strace perl -e 'utime 0, 4*10**17, "..."'
on a system where 4*10**17 fits in a time_t, but is not a valid time, such as x86_64 Linux systems.

The provided patch fixes this for systems where time_t is able to fit in a signed or unsigned long (signed negative values will be printed as very large numbers, but still uniquely identifiable). For full portability, it should also handle integral time_t wider than long, and floating time_t, but that is much more complicated. If you want to go for that, you might want to look at how GNU ls prints invalid mtimes.

Judging from the available patches and the committed patches, this will probably never even be looked at, but I cannot find where else to submit this.

Discussion

  • Nobody/Anonymous

    strace-4.5.15-invalid-time.patch

     
  • Eugene Syromyatnikov

    • status: open --> closed-fixed
    • Group: -->
     
  • Eugene Syromyatnikov

    Moved to https://github.com/strace/strace/issues/42
    Fixed in commit v4.21-163-ga02a583.