From: deraadt Date: Wed, 1 Sep 2021 20:01:14 +0000 (+0000) Subject: repair strtonum idiom and improve error messaging X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5ff327d0e2ba2b1014e48a26c3eaf52de090c0a7;p=openbsd repair strtonum idiom and improve error messaging ok job --- diff --git a/usr.bin/timeout/timeout.c b/usr.bin/timeout/timeout.c index 9cb0ea0b01d..15021466e65 100644 --- a/usr.bin/timeout/timeout.c +++ b/usr.bin/timeout/timeout.c @@ -111,21 +111,14 @@ parse_signal(const char *str) if (strcasecmp(str, sys_signame[i]) == 0) return (i); } - - goto err; + err(1, "invalid signal name"); } - errno = 0; - sig = strtonum(str, LONG_MIN, LONG_MAX, &errstr); + sig = strtonum(str, 1, NSIG, &errstr); if (errstr != NULL) - goto err; - if (sig >= NSIG || sig < 0) - goto err; + err(1, "signal %s %s", str, errstr); return (int)sig; - -err: - err(1, "invalid signal"); } static void