Module Name: src Committed By: dholland Date: Sat Jun 5 03:24:02 UTC 2010
Modified Files: src/usr.bin/last: last.c Log Message: Avoid SIGSEGV on out-of-range time_t. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/usr.bin/last/last.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/last/last.c diff -u src/usr.bin/last/last.c:1.33 src/usr.bin/last/last.c:1.34 --- src/usr.bin/last/last.c:1.33 Sun Apr 12 13:07:21 2009 +++ src/usr.bin/last/last.c Sat Jun 5 03:24:01 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: last.c,v 1.33 2009/04/12 13:07:21 lukem Exp $ */ +/* $NetBSD: last.c,v 1.34 2010/06/05 03:24:01 dholland Exp $ */ /* * Copyright (c) 1987, 1993, 1994 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)last.c 8.2 (Berkeley) 4/2/94"; #endif -__RCSID("$NetBSD: last.c,v 1.33 2009/04/12 13:07:21 lukem Exp $"); +__RCSID("$NetBSD: last.c,v 1.34 2010/06/05 03:24:01 dholland Exp $"); #endif /* not lint */ #include <sys/param.h> @@ -362,6 +362,10 @@ static char tbuf[TBUFLEN]; tm = (flags & GMT) ? gmtime(&t) : localtime(&t); + if (tm == NULL) { + strcpy(tbuf, "????"); + return tbuf; + } strftime(tbuf, sizeof(tbuf), (flags & TIMEONLY) ? (flags & FULLTIME ? LTFMTS : TFMTS)