svn commit: r219295 - stable/7/usr.bin/stat

Doug Barton dougb at FreeBSD.org
Sat Mar 5 04:08:07 UTC 2011


Author: dougb
Date: Sat Mar  5 04:08:07 2011
New Revision: 219295
URL: http://svn.freebsd.org/changeset/base/219295

Log:
  MFC r218535:
  
  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 at NetBSD.org

Modified:
  stable/7/usr.bin/stat/stat.c
Directory Properties:
  stable/7/usr.bin/stat/   (props changed)

Modified: stable/7/usr.bin/stat/stat.c
==============================================================================
--- stable/7/usr.bin/stat/stat.c	Sat Mar  5 04:06:12 2011	(r219294)
+++ stable/7/usr.bin/stat/stat.c	Sat Mar  5 04:08:07 2011	(r219295)
@@ -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
@@ -724,6 +724,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 |


More information about the svn-src-stable-7 mailing list