Disallow negative reps, they make no sense. While here, sscanf -> strtonum.
authorcheloha <cheloha@openbsd.org>
Wed, 1 Aug 2018 13:13:53 +0000 (13:13 +0000)
committercheloha <cheloha@openbsd.org>
Wed, 1 Aug 2018 13:13:53 +0000 (13:13 +0000)
From Kris Katterjohn on tech@.

ok tb@

usr.bin/jot/jot.c

index 1f7aacd..1c901b3 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: jot.c,v 1.46 2018/06/24 18:39:57 schwarze Exp $       */
+/*     $OpenBSD: jot.c,v 1.47 2018/08/01 13:13:53 cheloha Exp $        */
 /*     $NetBSD: jot.c,v 1.3 1994/12/02 20:29:43 pk Exp $       */
 
 /*-
@@ -153,8 +153,10 @@ main(int argc, char *argv[])
                }
        case 1:
                if (!is_default(argv[0])) {
-                       if (!sscanf(argv[0], "%ld", &reps))
-                               errx(1, "Bad reps value:  %s", argv[0]);
+                       reps = strtonum(argv[0], 0, LONG_MAX, &errstr);
+                       if (errstr != NULL)
+                               errx(1, "Bad reps value, %s: %s", errstr,
+                                   argv[0]);
                        mask |= REPS;
                        if (reps == 0)
                                infinity = true;