From nobody Thu Jul 13 21:37:26 2023 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 4R27HV4FM2z4mYPK; Thu, 13 Jul 2023 21:37:26 +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 4R27HV3BG1z3t8r; Thu, 13 Jul 2023 21:37:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689284246; 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=b6HZkKejzn6iAZljI1CA7unzBJFmd6W5MXTOajMNqy4=; b=Ena5uj0vaIPCmWAqjdYu0JH5qe5exhQSKTYjn6en1RjDELbgM0uTGgT1eRBOf35sT3lcg7 /nDcXRMsKx6fHkM/eyMloMzfRMHd3sNsrl0ulAtr2SI3uXSv5o3ZbcJlzCi+dbnXAhdm/6 C9JP7SvjCO4aCxtHyV6xsnQB5imQQ1jKeJOljm0vndDYJeGV7vJD90URxT4pLLZ9Gtepf+ 4D2AQxwRRLgeUBkF9IF/1YnDbSvtEB5JcDK21xOSdeLHrOEYjEy6wuBldzGYTIeDDRbVKn NyjBj3aAMrAE9k6sPlbBnulNpAK908KG5xU0cr+TMbawwu0HbsfFHjtY6qtlVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689284246; 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=b6HZkKejzn6iAZljI1CA7unzBJFmd6W5MXTOajMNqy4=; b=CXxPtz59wUuTWJrV90DT6xQvi6hB+EkDH5jurVB5eQZEViUOyINilVB/55S7ztdp2xgKDG U9MZmaVcml8UJX3uptrEB5Q4gD5q9LoTHfJssXBUPEC6Si4mObYPEAnMHZYMGSio7cGu27 rvoq19Vbyumj/JWd54oPjpwOxG0goTZ5Jfj0vQigrwa/04QxgC1ecqxd2vngO/AeO4GSKy I5AcBkLoc50zQGW8fvnkJQ8ViOmsmoTnlZdGC50Ao10lz94X5LBZr8xr9JioayDXqG83zN zhTv6repqB0TFT2b+7ZVs/XJJfil8HeOAO0n96tQcxZhaDEdHR0GJ/jLyIDnvA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1689284246; a=rsa-sha256; cv=none; b=gn9CJTwvVRQId33eatoU4eek/ia0iqLzR7ZYTx/wlAx4PBPYKEuOewEO/VYVp1wCvYmTXC QRqQQowJwiqXN0eIQyAcs/N8YZiD/DmYryT+1263+LjEdOY0Q2jIOgz+9MLu9MBjuUcEHb 71cjlphH98XRkHGGGTe1/EokNlJZicz237+iCcneghidbFMC0zUhVH05C4Sw2u3GraBDL4 JAs0WW6wnXdAqpbZ0f0x5Tszn7kLOQGMXcID9iey4hOEFi+JIBFUVb0YUemZNSAnimVDon D7Ad5WlgBcKfP7eyP21rbgG2aQKkkhnvnEWFGqu2wdEOcyAmYc13Cavfi6qaww== 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 4R27HV2F48z16P2; Thu, 13 Jul 2023 21:37:26 +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 36DLbQVA022824; Thu, 13 Jul 2023 21:37:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36DLbQ0R022823; Thu, 13 Jul 2023 21:37:26 GMT (envelope-from git) Date: Thu, 13 Jul 2023 21:37:26 GMT Message-Id: <202307132137.36DLbQ0R022823@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Dag-Erling=20Sm=C3=B8rgrav?= Subject: git: eab91d008165 - main - xargs: Prevent overflow in linelen calculation if nargs is large. 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/main X-Git-Reftype: branch X-Git-Commit: eab91d008165e7bbf8ca7b87eabe4dc8bf3da191 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=eab91d008165e7bbf8ca7b87eabe4dc8bf3da191 commit eab91d008165e7bbf8ca7b87eabe4dc8bf3da191 Author: Dag-Erling Smørgrav AuthorDate: 2023-07-13 20:06:40 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2023-07-13 21:35:23 +0000 xargs: Prevent overflow in linelen calculation if nargs is large. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D41023 --- usr.bin/xargs/tests/regress.n2147483647.out | 1 + usr.bin/xargs/tests/regress.sh | 1 + usr.bin/xargs/xargs.c | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/usr.bin/xargs/tests/regress.n2147483647.out b/usr.bin/xargs/tests/regress.n2147483647.out new file mode 100644 index 000000000000..cc32a92a2199 --- /dev/null +++ b/usr.bin/xargs/tests/regress.n2147483647.out @@ -0,0 +1 @@ +quick brown fox jumped over the lazy dog diff --git a/usr.bin/xargs/tests/regress.sh b/usr.bin/xargs/tests/regress.sh index ed81d66bf2a6..fed3ab9c8461 100644 --- a/usr.bin/xargs/tests/regress.sh +++ b/usr.bin/xargs/tests/regress.sh @@ -5,6 +5,7 @@ echo 1..21 REGRESSION_START($1) REGRESSION_TEST(`normal', `xargs echo The <${SRCDIR}/regress.in') +REGRESSION_TEST(`n2147483647', `xargs -n2147483647 <${SRCDIR}/regress.in') REGRESSION_TEST(`I', `xargs -I% echo The % % % %% % % <${SRCDIR}/regress.in') REGRESSION_TEST(`J', `xargs -J% echo The % again. <${SRCDIR}/regress.in') REGRESSION_TEST(`L', `xargs -L3 echo <${SRCDIR}/regress.in') diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c index e6f8619bb8d1..cd6b7da1a186 100644 --- a/usr.bin/xargs/xargs.c +++ b/usr.bin/xargs/xargs.c @@ -257,7 +257,7 @@ main(int argc, char *argv[]) * the maximum arguments to be read from stdin and the trailing * NULL. */ - linelen = 1 + argc + nargs + 1; + linelen = 1 + argc + (size_t)nargs + 1; if ((av = bxp = malloc(linelen * sizeof(char *))) == NULL) errx(1, "malloc failed");