From 5ff327d0e2ba2b1014e48a26c3eaf52de090c0a7 Mon Sep 17 00:00:00 2001 From: deraadt Date: Wed, 1 Sep 2021 20:01:14 +0000 Subject: [PATCH] repair strtonum idiom and improve error messaging ok job --- usr.bin/timeout/timeout.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) 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 -- 2.20.1