From nobody Mon May 06 06:04:08 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 4VXrT42bKkz5JLYq; Mon, 06 May 2024 06:04:08 +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 4VXrT42806z4fMj; Mon, 6 May 2024 06:04:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714975448; 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=XLxmW9NGO6Z/gYlhh3NRBjKJJFoxKWcwqHt9iDeyAtE=; b=CHrx0Tgy22egkiuw78X34lV/0VyFXx8qLS/vpw27s0HxDt51SSclnMVAzsO4QsT4dKzq3A QOTGnlZrx2SvJSB4nbajp7XrS7ggQM9r/D1NHA0QmUToL5I696E5btOBuqBN3bT6cePa9U LfFfOZL5TxijQPdqRc8Arjw1XHNOleoN81M4TutQ8rf/nlj8ujAkx53MR4PWTrHUv+y+mm eR3ueyup3ctIUCbpNQPNISTwif+63zXdJEVoVVrk2/W5GqKQgz45yxGZBb+0YZcwflQ4B+ Kwab5JVbapsyjn+EciIw5VFduWQRCeFwASU33972joW568/jSGlWN4eypId8Dw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1714975448; a=rsa-sha256; cv=none; b=Hmwvh0fCqINxMRa60+L0YsQRSt+s3KEZTYw1XYB1gQPOpNaLHPyjEkhgnLQvqc6WuWtYH5 5waoYv61mvkwXKPcfi/4WjaJYVq/w+lJfMwcyJAkQDFDgpTjrzcHkEuG7jK/LZT90SXRgA KvBGy7oWH9LQ3cX47es6r8a93ez0haNOHN2lzx8CU5KKs46s1F2Drc+bIXeYwzkTDLblY1 FbiAoLyFz0AMSTJyuyymfQXqGFstlcgKQiVNURVrhbBOWDsWqep0BcaIAep3xR86deEZ9s MmaiBz6qINo9wjRW/ebLFAXKo0yNE/eKPfgzCJmNK5MUuPzZCQlogNmuWBXO/Q== 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=1714975448; 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=XLxmW9NGO6Z/gYlhh3NRBjKJJFoxKWcwqHt9iDeyAtE=; b=HOKssFyMvOMxWnXIffAYULK7ViLtv7/1mstb7lroIGqKfwyuTAD1X6e3sWzw2N8SLkA5uK Q09d0n8b1zi/EPf4C2/+UGpqHA3HpEubp0DFx577MBoo2KqJ/p14DnGtBDBkN8W2Lep5pw lQ8aGEmOy0d8FwoVwczgHBzhxVRg59iMn98Hy2y0o1yeqKBqt8oNNXyBmTM2i1Hz14rPG6 8Ohlt4z61yvkXj0wWvZUquaaQKACSEJ4ga0/P05ZoVspLbzywJWZqBy0DwrfxsiYSWcays PC09b0tu9iUFWFUkC+pseE9+arHXTRbsjdcN3jr+rhE+UU0liHvcb7+ZNFillw== 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 4VXrT41ZcTzlZY; Mon, 6 May 2024 06:04:08 +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 4466487J086135; Mon, 6 May 2024 06:04:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 446648lR086132; Mon, 6 May 2024 06:04:08 GMT (envelope-from git) Date: Mon, 6 May 2024 06:04:08 GMT Message-Id: <202405060604.446648lR086132@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Xin LI Subject: git: 45764d1d4856 - stable/14 - Tighten boundary check in split(1) to prevent a potential buffer overflow. 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: delphij X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 45764d1d4856954fbfc48c11a715fad88821b135 Auto-Submitted: auto-generated The branch stable/14 has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=45764d1d4856954fbfc48c11a715fad88821b135 commit 45764d1d4856954fbfc48c11a715fad88821b135 Author: Shawn Bayern AuthorDate: 2024-05-03 07:46:18 +0000 Commit: Xin LI CommitDate: 2024-05-06 05:59:08 +0000 Tighten boundary check in split(1) to prevent a potential buffer overflow. (cherry picked from commit 95032b58a1ad0fde57518f17805ca721bb4563ad) --- usr.bin/split/split.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/usr.bin/split/split.c b/usr.bin/split/split.c index e246a0d4adfc..52374c93efca 100644 --- a/usr.bin/split/split.c +++ b/usr.bin/split/split.c @@ -401,6 +401,10 @@ newfile(void) */ if (!dflag && autosfx && (fpnt[0] == 'y') && strspn(fpnt+1, "z") == strlen(fpnt+1)) { + /* Ensure the generated filenames will fit into the buffer. */ + if (strlen(fname) + 2 >= sizeof(fname)) + errx(EX_USAGE, "combined filenames would be too long"); + fpnt = fname + strlen(fname) - sufflen; fpnt[sufflen + 2] = '\0'; fpnt[0] = end;