From nobody Wed Jan 17 18:28:40 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TFZBx01mcz56PGC; Wed, 17 Jan 2024 18:28:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TFZBw6Cc4z4cHx; Wed, 17 Jan 2024 18:28:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705516120; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NOE95pvyqqiAs+KeGc1YWdjTBrpJ+Lu0yGu/AI475cY=; b=YZ4MEQHFGsYIOV2xCaTWsRzazwT+20f3FjXPJFA6jPNXpjRRGQQ1R57l5rX6VLTkcS0Sre 1KMEOjXr6lmo/kFd7Y4WaXlpGbG6XbFZMCbgvaCBhC/IQXmwXhcVRqI/wwzAheI56UEF5E g/zCKqg/5KWZ3adkNEi2OHbV+SrMk1zmZl82O/FgTFwa8J6wOvcQ70Xaqj7HZR9bmwz3RQ H9BVdHaVvEIbFfCv+bo2YOzeJc0wSxIJk6c1cuhrStRp34Mrz2TISP0aWmIuZL/oq5G3h1 8UwYW4M7gWM3v1Z6z+z9Uusitwli35cpMS/gPo9q7LP4dpNwBDJKcYDVSGjCBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705516120; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=NOE95pvyqqiAs+KeGc1YWdjTBrpJ+Lu0yGu/AI475cY=; b=Lr6FdETB5Zrh1puhJbyPrTdbjbCxdOAnD4nkv0v6y1cbSGRC7AilGtJqmNCdDdxymH6uSG fRgNGMuiBRoE8LESbS4b/2K2dfl+Dbh7MQAQ5BSTSiqbn8ye1HRAHSLm+pc40jRbJYVjeN ZzL5DT47qHndPD3CX+NG3uv1QYyDqiGZH/uZvf6PzrgHtvMXh9eedPVKm2XmpzQANQbmNV auvRswB8ZN77WqHWNu1MZD9GNDfpbK5BSkRrxQTfXwMXtbUH212cCcizg8r/7ROpum8R+H ViAZjzI4G9sx8xxgagbMacVegIA/JZMr9B5gNpTNGS/82FBjTDCDdTTaOwravw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705516120; a=rsa-sha256; cv=none; b=Bx3O/X7Q8s0s7H9W23uMkdL8bSOPRMCaCveHQUyT8frO0zmJbVbKBBpm141LS7GwWruBGv /2Lv/z3gtqalxgS1u7jFN0lHPhP6GxbCWz2Yp2AjYyUpegxaakHCqEIsuaMDWuV/j0Xj4b FtHDEvlZeRHl5uP0l0V6A5VqkanL9g2ekQjNfiyvo9KWW9AVrC+Lr6d5Xuom67x+cCBpzW e8bol5VUZ6jgg847t5/GwI+MEcq3ntmcjMOkvpENHxDd6LkchFyAorH5okxaBHJb3mKQ7c eSTlWkvsQ4DMx+6z7fB6YglvyBM4vuoBiJelYW5cNQVy3dBqic2ivyrH4KGrUw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TFZBw5KJZzZkp; Wed, 17 Jan 2024 18:28:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40HISekr063938; Wed, 17 Jan 2024 18:28:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40HISerV063935; Wed, 17 Jan 2024 18:28:40 GMT (envelope-from git) Date: Wed, 17 Jan 2024 18:28:40 GMT Message-Id: <202401171828.40HISerV063935@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: 4cf7301e9683 - stable/13 - uniq(1): use strtonum to parse options List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4cf7301e96833970cc42c6f75b8068eb51abdd37 Auto-Submitted: auto-generated The branch stable/13 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=4cf7301e96833970cc42c6f75b8068eb51abdd37 commit 4cf7301e96833970cc42c6f75b8068eb51abdd37 Author: Daniel Tameling AuthorDate: 2023-02-25 17:25:51 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-01-17 16:16:01 +0000 uniq(1): use strtonum to parse options Previously strtol was used and the result was directly cast to an int without checking for an overflow. Use strtonum instead since it is safer and tells us what went wrong. Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/643 (cherry picked from commit e052829e3e16dfd82d0adcbb69fd0e30f47a3a6c) --- usr.bin/uniq/uniq.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/usr.bin/uniq/uniq.c b/usr.bin/uniq/uniq.c index 59676a26e1f8..1513ae185bcf 100644 --- a/usr.bin/uniq/uniq.c +++ b/usr.bin/uniq/uniq.c @@ -100,7 +100,7 @@ main (int argc, char *argv[]) int ch, comp; size_t prevbuflen, thisbuflen, b1; char *prevline, *thisline, *p; - const char *ifn; + const char *ifn, *errstr;; cap_rights_t rights; (void) setlocale(LC_ALL, ""); @@ -129,14 +129,14 @@ main (int argc, char *argv[]) iflag = 1; break; case 'f': - numfields = strtol(optarg, &p, 10); - if (numfields < 0 || *p) - errx(1, "illegal field skip value: %s", optarg); + numfields = strtonum(optarg, 0, INT_MAX, &errstr); + if (errstr) + errx(1, "field skip value is %s: %s", errstr, optarg); break; case 's': - numchars = strtol(optarg, &p, 10); - if (numchars < 0 || *p) - errx(1, "illegal character skip value: %s", optarg); + numchars = strtonum(optarg, 0, INT_MAX, &errstr); + if (errstr != NULL) + errx(1, "character skip value is %s: %s", errstr, optarg); break; case 'u': uflag = 1;