From nobody Thu Aug 08 21:23:16 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 4Wg0QF1zlLz5SK0y; Thu, 08 Aug 2024 21:23:17 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Wg0QD6vbgz40Yk; Thu, 8 Aug 2024 21:23:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723152197; 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=bxlWw0onzr2Kh2kAuwWRViOBfisnHYgxqcwVgSK12EA=; b=yjZYvj2TFdWYp5OV1FtLzrPxa+XOEKgwtPBV8fp6NF0ioVJHT+WtyRazrzqRV4Br5/nzHh SLw53r88mNbTFEnvmD7yDPFL9Vs8OZrYGJiGW+qqmQTGh/ktc+yI8GHB1hCx9N/iBU4xBw szfk70kGH1AX5rr49TUyx1GeP5U7Hz4w2tYX8yMNCbQ6WVTGd3Q0xG9DRdM+Y96ae42MXM yp/rtfMe1PKnhtEYWLOQRgI5+NBWu1IaIot7U15w3rLm98zIngnCVGxzQNHfHaCKKCNI09 3vVM7qa1hSCWbfeijjVKN+tYTC7u2P0xKgW0mv5XS/j3PlwlPRzzk1gBPUOlpQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1723152197; a=rsa-sha256; cv=none; b=hNtkfDPPiiqCXnXo4+OscQeFD8iv3nKRLfkxE1GWWuLRDldT5Z4ktKVrU74IYnTy5yaZ9G DsZBxaq5d9Pf36bLnkYt2aovdedRPAuArY027z8YD8+fuJg5/yDUyqH+u6bt4iqVcb8fFN 9/9L4VcOkNJA2lIUx5eOI7MzfCFt2AfBQgHvWSda1KSzSyN9o3ODwnjYbpeVVvrApB5pJU klUC38aG9Xm2PR4fUec4mmkJasH2JICvSB+aUE6ZmdxV0O7axQOQkJa9qdg5LuSruMmbTM YPuGvveBKaX/jfBcQ9nos1l4ShChYIPZt3DZZUreT72zv1hw9JxH8VfjGRZrng== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1723152197; 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=bxlWw0onzr2Kh2kAuwWRViOBfisnHYgxqcwVgSK12EA=; b=DEih0Q6c/A97Z6L+v9FvMnmzkm0pzIFyAVNUF2ikf7j8xNvMELw9B2EJy4mJi8valtCeol GL0Ft4yATkLH6hM2SpJJEJML++S4Hey+c5JN1JjqPzgNATLRtufHkoija9VllBPrGD7mLR Sw8S1r1SrV5qIXNPrNUi7qMKaZtdsVsN95P/1xSk4vdHzQdW+wJVRb91drf85dyWCLU6N1 LXX+RH443Z3nfgTVQGRthLowwUx6BhOy2fUs9or9s/wQ9F/vtTvciV5W4Iy4XTUBaPlrOs vPCwlIpNRDxR6C93f3SEb48BH0z353DQYGo0nuoKW5o+ZW8DCTLAb8G842OxUw== 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 4Wg0QD6WSNzpsh; Thu, 8 Aug 2024 21:23:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 478LNGp1052727; Thu, 8 Aug 2024 21:23:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 478LNGrk052724; Thu, 8 Aug 2024 21:23:16 GMT (envelope-from git) Date: Thu, 8 Aug 2024 21:23:16 GMT Message-Id: <202408082123.478LNGrk052724@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Poul-Henning Kamp Subject: git: 06758ab1340e - main - Use expand_number(3) for less confusing argument processing 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: phk X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 06758ab1340e652930b573f8fd3d858f064d9204 Auto-Submitted: auto-generated The branch main has been updated by phk: URL: https://cgit.FreeBSD.org/src/commit/?id=06758ab1340e652930b573f8fd3d858f064d9204 commit 06758ab1340e652930b573f8fd3d858f064d9204 Author: Poul-Henning Kamp AuthorDate: 2024-08-08 21:22:39 +0000 Commit: Poul-Henning Kamp CommitDate: 2024-08-08 21:22:39 +0000 Use expand_number(3) for less confusing argument processing --- usr.bin/tcopy/Makefile | 1 + usr.bin/tcopy/tcopy.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/usr.bin/tcopy/Makefile b/usr.bin/tcopy/Makefile index 86eb0dd42165..73dcd45b2e0f 100644 --- a/usr.bin/tcopy/Makefile +++ b/usr.bin/tcopy/Makefile @@ -1,3 +1,4 @@ PROG= tcopy +LIBADD= util .include diff --git a/usr.bin/tcopy/tcopy.c b/usr.bin/tcopy/tcopy.c index aa39bce77845..39eae4126324 100644 --- a/usr.bin/tcopy/tcopy.c +++ b/usr.bin/tcopy/tcopy.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -71,6 +72,7 @@ main(int argc, char *argv[]) const char *inf; unsigned long maxphys = 0; size_t l_maxphys = sizeof maxphys; + uint64_t tmp; if (!sysctlbyname("kern.maxphys", &maxphys, &l_maxphys, NULL, 0)) maxblk = maxphys; @@ -84,8 +86,12 @@ main(int argc, char *argv[]) op = COPYVERIFY; break; case 's': - maxblk = atoi(optarg); - if (maxblk <= 0) { + if (expand_number(optarg, &tmp)) { + warnx("illegal block size"); + usage(); + } + maxblk = tmp; + if (maxblk == 0) { warnx("illegal block size"); usage(); }