summaryrefslogtreecommitdiff
path: root/bin/date
diff options
context:
space:
mode:
Diffstat (limited to 'bin/date')
-rw-r--r--bin/date/date.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/bin/date/date.c b/bin/date/date.c
index 5cb0cd0f7e0..fb36c9bf3bc 100644
--- a/bin/date/date.c
+++ b/bin/date/date.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: date.c,v 1.42 2014/01/05 05:27:44 schwarze Exp $ */
+/* $OpenBSD: date.c,v 1.43 2014/01/21 09:09:15 otto Exp $ */
/* $NetBSD: date.c,v 1.11 1995/09/07 06:21:05 jtc Exp $ */
/*
@@ -60,6 +60,7 @@ int
main(int argc, char *argv[])
{
struct timezone tz;
+ struct tm *tp;
int ch, rflag;
char *format, buf[1024], *outzone = NULL;
@@ -139,7 +140,10 @@ main(int argc, char *argv[])
if (outzone)
setenv("TZ", outzone, 1);
- (void)strftime(buf, sizeof(buf), format, localtime(&tval));
+ tp = localtime(&tval);
+ if (tp == NULL)
+ errx(1, "conversion error");
+ (void)strftime(buf, sizeof(buf), format, tp);
(void)printf("%s\n", buf);
exit(0);
}