ok?

Index: bin/date/date.c
===================================================================
RCS file: /cvs/src/bin/date/date.c,v
retrieving revision 1.51
diff -u -p -r1.51 date.c
--- bin/date/date.c     23 Dec 2017 20:58:14 -0000      1.51
+++ bin/date/date.c     12 Feb 2018 16:29:24 -0000
@@ -36,6 +36,7 @@
 #include <ctype.h>
 #include <err.h>
 #include <fcntl.h>
+#include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -78,7 +79,9 @@ main(int argc, char *argv[])
                        break;
                case 'r':               /* user specified seconds */
                        rflag = 1;
-                       tval = atoll(optarg);
+                       tval = strtonum(optarg, LLONG_MIN, LLONG_MAX, &errstr);
+                       if (errstr)
+                               errx(1, "seconds is %s: %s", errstr, optarg);
                        break;
                case 'u':               /* do everything in UTC */
                        if (setenv("TZ", "UTC", 1) == -1)

Reply via email to