diff options
author | dougb <dougb@FreeBSD.org> | 2011-02-11 05:33:35 +0000 |
---|---|---|
committer | dougb <dougb@FreeBSD.org> | 2011-02-11 05:33:35 +0000 |
commit | 05202850ffbc658e49952ced354842502c90589a (patch) | |
tree | 82d1ce930604fe32fc868557a11b331e4c557648 /usr.bin | |
parent | 9d26fecad6d2e2ed112caf19320e8f94ead5993a (diff) | |
download | FreeBSD-src-05202850ffbc658e49952ced354842502c90589a.zip FreeBSD-src-05202850ffbc658e49952ced354842502c90589a.tar.gz |
Synthesize the change from NetBSD's 1.33:
"Do not crash if a date cannot be represented (localtime returning
NULL), use the Epoch value instead."
Obtained from: njoly@NetBSD.org
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/stat/stat.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.bin/stat/stat.c b/usr.bin/stat/stat.c index b2ba03f..31e2bd9 100644 --- a/usr.bin/stat/stat.c +++ b/usr.bin/stat/stat.c @@ -30,7 +30,7 @@ #include <sys/cdefs.h> #if 0 #ifndef lint -__RCSID("$NetBSD: stat.c,v 1.31 2010/12/16 05:30:16 dholland Exp $" +__RCSID("$NetBSD: stat.c,v 1.33 2011/01/15 22:54:10 njoly Exp $" "$OpenBSD: stat.c,v 1.14 2009/06/24 09:44:25 sobrado Exp $"); #endif #endif @@ -731,6 +731,10 @@ format1(const struct stat *st, small = (sizeof(ts.tv_sec) == 4); data = ts.tv_sec; tm = localtime(&ts.tv_sec); + if (tm == NULL) { + ts.tv_sec = 0; + tm = localtime(&ts.tv_sec); + } (void)strftime(path, sizeof(path), timefmt, tm); sdata = path; formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX | |