Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Feb 2011 05:33:36 +0000 (UTC)
From:      Doug Barton <dougb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r218535 - head/usr.bin/stat
Message-ID:  <201102110533.p1B5XaQZ046660@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dougb
Date: Fri Feb 11 05:33:35 2011
New Revision: 218535
URL: http://svn.freebsd.org/changeset/base/218535

Log:
  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

Modified:
  head/usr.bin/stat/stat.c

Modified: head/usr.bin/stat/stat.c
==============================================================================
--- head/usr.bin/stat/stat.c	Fri Feb 11 04:03:39 2011	(r218534)
+++ head/usr.bin/stat/stat.c	Fri Feb 11 05:33:35 2011	(r218535)
@@ -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 |



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201102110533.p1B5XaQZ046660>