From nobody Mon May 06 06:05:04 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 4VXrV85rnZz5JLkZ; Mon, 06 May 2024 06:05:04 +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 4VXrV858NKz4fRZ; Mon, 6 May 2024 06:05:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714975504; 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=Pg1g5NjCvdfHRbwHeEcbaCnXr8+yGFvHj0twezqgv7Y=; b=g1mCI+EDo55KjSllsocjo9mWxmHVdxyO94aag2pW7vhUxNY0JOQfHbx6BD0bp7mtqzmEqm 0sQo1T53m2RV62A63uTzxTuhfOLk3T6nz5xJINoTRBtW8lRvBR1ipifsEO9stz36ZLPYw/ i5rlxJ3tPETOG01ofIcrzIsjRMzq409wZR2zBWkp5+ZZOr9CgJpH+QuL0Qsp8V895wi3Lm Xpu3W2LsY0z3ZdcZ/nGFWRwCAOi9dvJw67wrNrvzgdnGO299p7ygQigbyH3FVhvqRCNZVS M/ryZaUzq3+fDhrBa2An0Zm8o0RoISx/lpiFdCR7UeJWGF9jowgfrvCqyTpBjw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1714975504; a=rsa-sha256; cv=none; b=tis85CWFLSEXuBkrY51+cpqRzpOdK1nHJTaqNLXtQSEMM/m+H9ddAVQuXOnikHbp2IzFu0 yGW2yRegOSmxoetftyXYAW2uPq1xDzCL8TN9csHHN+p7INzQBaBgQ+efwSuKrwOVOZCxvF VQfdszDPBxlXWs/bEtvQGRFjq6SIiwpaDyD31502++pLudODzkUrDj7g6qNpAuewN2qo4l i4bLmEWHw8rF0QOV2rgQGdImGFWPJxU3WWnJzZniNsfHENKaga0pjgNivcHF3qWPNUO5Gj o5Q42veiHHDROmoW/twQazRAMgAQ0OUDNqcjGgt9ySME1YZrvoFV19jfjgCrTA== 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=1714975504; 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=Pg1g5NjCvdfHRbwHeEcbaCnXr8+yGFvHj0twezqgv7Y=; b=AAA3+ahNTha72HJMRv8MxDyx90oehux0TVqukefPMO5cGjmwDf74zN8axtAR3HsIe+RfeS eWv78HCkQxmXiADk+aIH2sw/Tp6XYBA97LtVGv30bv3QzD/kg5aknu274b2HUgT8s84YAT 3j8NePSnMnpGmy6VRSalQ7ixXf/w9VObSZeVDdTplRW1kFbFPRZyw1IG2m+tVvZlUX+9Kn ENiCB1CVbWVCpqH2v6COUMEwcEQNJRJfsA3ZTzRcXyP4Wd3KVz7E7j2eevr/FjDTJId6Pl mJGZUvNfnwdEG9RdmXawzVtxAyLzTQK7OUETHAYZpOJ9IEEAEVDUq3XoUPtguQ== 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 4VXrV84X7lzm12; Mon, 6 May 2024 06:05:04 +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 446654Nj086433; Mon, 6 May 2024 06:05:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4466540j086430; Mon, 6 May 2024 06:05:04 GMT (envelope-from git) Date: Mon, 6 May 2024 06:05:04 GMT Message-Id: <202405060605.4466540j086430@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: 6290fc5eeffc - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: 6290fc5eeffc2cb145c1715d9b2a1ccf996660b6 Auto-Submitted: auto-generated The branch stable/13 has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=6290fc5eeffc2cb145c1715d9b2a1ccf996660b6 commit 6290fc5eeffc2cb145c1715d9b2a1ccf996660b6 Author: Shawn Bayern AuthorDate: 2024-05-03 07:46:18 +0000 Commit: Xin LI CommitDate: 2024-05-06 06:04:43 +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;