From 1c8ab742597255b39052a8353fc401623f85ca76 Mon Sep 17 00:00:00 2001 From: cheloha Date: Wed, 1 Aug 2018 13:13:54 +0000 Subject: Disallow negative reps, they make no sense. While here, sscanf -> strtonum. From Kris Katterjohn on tech@. ok tb@ --- usr.bin/jot/jot.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'usr.bin/jot/jot.c') 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; -- cgit v1.2.3