From owner-svn-src-stable-7@FreeBSD.ORG Sat Mar 5 04:08:07 2011 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 985991065670; Sat, 5 Mar 2011 04:08:07 +0000 (UTC) (envelope-from dougb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 859428FC16; Sat, 5 Mar 2011 04:08:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p25487PD004161; Sat, 5 Mar 2011 04:08:07 GMT (envelope-from dougb@svn.freebsd.org) Received: (from dougb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p254875B004159; Sat, 5 Mar 2011 04:08:07 GMT (envelope-from dougb@svn.freebsd.org) Message-Id: <201103050408.p254875B004159@svn.freebsd.org> From: Doug Barton Date: Sat, 5 Mar 2011 04:08:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r219295 - stable/7/usr.bin/stat X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Mar 2011 04:08:07 -0000 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@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 #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 |