Module Name: src
Committed By: njoly
Date: Sat Jan 15 22:54:11 UTC 2011
Modified Files:
src/usr.bin/stat: stat.c
Log Message:
Do not crash if a date cannot be represented (localtime returning
NULL), use the Epoch value instead.
To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/stat/stat.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/stat/stat.c
diff -u src/usr.bin/stat/stat.c:1.32 src/usr.bin/stat/stat.c:1.33
--- src/usr.bin/stat/stat.c:1.32 Thu Dec 16 05:42:14 2010
+++ src/usr.bin/stat/stat.c Sat Jan 15 22:54:10 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: stat.c,v 1.32 2010/12/16 05:42:14 dholland Exp $ */
+/* $NetBSD: stat.c,v 1.33 2011/01/15 22:54:10 njoly Exp $ */
/*
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
-__RCSID("$NetBSD: stat.c,v 1.32 2010/12/16 05:42:14 dholland Exp $");
+__RCSID("$NetBSD: stat.c,v 1.33 2011/01/15 22:54:10 njoly Exp $");
#endif
#if ! HAVE_NBTOOL_CONFIG_H
@@ -719,6 +719,10 @@
small = (sizeof(secs) == 4);
data = secs;
tm = localtime(&secs);
+ if (tm == NULL) {
+ secs = 0;
+ tm = localtime(&secs);
+ }
(void)strftime(path, sizeof(path), timefmt, tm);
sdata = path;
formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX |