diff options
author | cheloha <cheloha@cvs.openbsd.org> | 2018-08-01 13:13:54 +0000 |
---|---|---|
committer | cheloha <cheloha@cvs.openbsd.org> | 2018-08-01 13:13:54 +0000 |
commit | 1c8ab742597255b39052a8353fc401623f85ca76 (patch) | |
tree | 74d508a890d2cacce9ef5f1fae2d33f06d0e90f9 /usr.bin/jot/jot.c | |
parent | d9953a69d6cf64e888c918220ee088b48a9bb5a2 (diff) |
Disallow negative reps, they make no sense. While here, sscanf -> strtonum.
From Kris Katterjohn on tech@.
ok tb@
Diffstat (limited to 'usr.bin/jot/jot.c')
-rw-r--r-- | usr.bin/jot/jot.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/jot/jot.c b/usr.bin/jot/jot.c index 1f7aacd1dcf..1c901b3be8b 100644 --- a/usr.bin/jot/jot.c +++ b/usr.bin/jot/jot.c @@ -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; |