[Midnightbsd-cvs] src [11350] trunk/bin/date/date.c: add error handling
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Fri Jul 6 08:02:25 EDT 2018
Revision: 11350
http://svnweb.midnightbsd.org/src/?rev=11350
Author: laffer1
Date: 2018-07-06 08:02:24 -0400 (Fri, 06 Jul 2018)
Log Message:
-----------
add error handling
Modified Paths:
--------------
trunk/bin/date/Makefile
trunk/bin/date/date.1
trunk/bin/date/date.c
Property Changed:
----------------
trunk/bin/date/date.1
Modified: trunk/bin/date/Makefile
===================================================================
--- trunk/bin/date/Makefile 2018-07-06 12:01:37 UTC (rev 11349)
+++ trunk/bin/date/Makefile 2018-07-06 12:02:24 UTC (rev 11350)
@@ -1,6 +1,6 @@
+# $MidnightBSD$
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $FreeBSD: stable/10/bin/date/Makefile 262951 2014-03-09 17:04:31Z jmmv $
-# $MidnightBSD$
.include <bsd.own.mk>
@@ -7,4 +7,8 @@
PROG= date
SRCS= date.c netdate.c vary.c
+.if ${MK_TESTS} != "no"
+SUBDIR+= tests
+.endif
+
.include <bsd.prog.mk>
Modified: trunk/bin/date/date.1
===================================================================
--- trunk/bin/date/date.1 2018-07-06 12:01:37 UTC (rev 11349)
+++ trunk/bin/date/date.1 2018-07-06 12:02:24 UTC (rev 11350)
@@ -31,7 +31,7 @@
.\"
.\" @(#)date.1 8.3 (Berkeley) 4/28/95
.\" $FreeBSD: src/bin/date/date.1,v 1.72 2005/02/13 22:25:09 ru Exp $
-.\" $MidnightBSD: src/bin/date/date.1,v 1.3 2008/06/30 02:45:42 laffer1 Exp $
+.\" $MidnightBSD$
.\"
.Dd May 7, 2015
.Dt DATE 1
Property changes on: trunk/bin/date/date.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/bin/date/date.c
===================================================================
--- trunk/bin/date/date.c 2018-07-06 12:01:37 UTC (rev 11349)
+++ trunk/bin/date/date.c 2018-07-06 12:02:24 UTC (rev 11350)
@@ -26,7 +26,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-/* $FreeBSD: src/bin/date/date.c,v 1.47 2005/01/10 08:39:21 imp Exp $ */
#ifndef lint
static char const copyright[] =
@@ -86,7 +85,7 @@
int set_timezone;
struct vary *v;
const struct vary *badv;
- struct tm lt;
+ struct tm *lt;
struct stat sb;
v = NULL;
@@ -175,8 +174,10 @@
if (*argv && **argv == '+')
format = *argv + 1;
- lt = *localtime(&tval);
- badv = vary_apply(v, <);
+ lt = localtime(&tval);
+ if (lt == NULL)
+ errx(1, "invalid time");
+ badv = vary_apply(v, lt);
if (badv) {
fprintf(stderr, "%s: Cannot apply date adjustment\n",
badv->arg);
@@ -192,7 +193,7 @@
*/
setlocale(LC_TIME, "C");
- (void)strftime(buf, sizeof(buf), format, <);
+ (void)strftime(buf, sizeof(buf), format, lt);
(void)printf("%s\n", buf);
if (fflush(stdout))
err(1, "stdout");
@@ -211,6 +212,8 @@
int century;
lt = localtime(&tval);
+ if (lt == NULL)
+ errx(1, "invalid time");
lt->tm_isdst = -1; /* divine correct DST */
if (fmt != NULL) {
More information about the Midnightbsd-cvs
mailing list