From nobody Fri Jun 21 16:43:25 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 4W5NTV0dxjz5NxcH; Fri, 21 Jun 2024 16:43: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 4W5NTT6y1Hz44Zh; Fri, 21 Jun 2024 16:43:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718988206; 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=K2A8OHarNlqdYtqXBqytvlDyb1Ya2IQZC70G9Fn1gjI=; b=nZaAUQ3rVer/HPMu5eFyFeqqS6kkoBqq8rszYQsEtpyf7TLztQ+Wwh0wWJbrY2bQibHO+k EjthI4W1AmkuYqtv9ZBPhdDic9nHFUzfik9Vh6qP24TXWgo3A+qeo5DOhNhB58l534JTIc nQNEcObnQstwa3dJSWs2rTia+tw/APqKfMwsOAjXajRAW1kJhBbXckDifpBXc4N/az8I6w 5ck1NkYsEP2CSmeUvC6OrbJZ0x4AXKCKtQSsOLaw7YmIxRouCZqg4fb5rs/GjlrG46mqnk lb+M5m4uexC8WEHT8JilA04vDawjNbCDNAtBoiLpX3usBczwgOPbFLDMocVynA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1718988206; a=rsa-sha256; cv=none; b=XOpbjbCWVU8Wbqe6d2beYjaSA6d9X3zhzl213Gv8pWvVgWkD9e1JbWfZXoXjqrqfmnxD05 AZo19wiJ0KWCxBmyEYjqhI4XM1k7aJIwxbcpVFRK+jmT7ZGGSE+Hj4rcMywUiSRtbBhD4j q2jxbvcQb3d9fwXPFZzqY/n35VH7FYoXhD6NhG/sZ2whCe7hWAnBGuTJRycFkGjgBVv+6x Jvl2kzMQYhfgBxJJyLKAkwRZytWskx9BUZdVHDiGSEq+rVCPdQuIAZ7Gi+gc2FlF4jlP7T XLrJ0G3vshh4dmXLQnBOLDldcPDLFTuXFiwHLA4IVHvR5rsiQOXIKven8E0Avw== 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=1718988206; 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=K2A8OHarNlqdYtqXBqytvlDyb1Ya2IQZC70G9Fn1gjI=; b=eIrKn6uQLtPbaTheefiDC2v+8SgHEtLo7rEIVH/SjYaSNgRvHDHjUtpvcjd1/Fq0rlBmDJ D17RuhQhTT64XldcVy0ZjtQkZbse7laAVp1nAQdtlfHu+boPr0do94YlukIP8lEUbIINA4 ATjYjCQ+eJoFxVO4vt31ETNZozeJr/Yuk0TXIEy7VUa8Gl+muydwUWJGvUFsaZT5DRHVaW 8egj8XAYqjJ6POl+9jJRyzxfIcewBvF+0ff+xTQVgNCHzj7Q6E2KYGvLJM077DMk3b8OFn pccrr69Qs273ZsgfkVaZYYqpcGion2csGW7zYwqiPBvcUXHHWbC65G6hOi5EJg== 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 4W5NTT6Y5lzG3C; Fri, 21 Jun 2024 16:43:25 +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 45LGhPQU084021; Fri, 21 Jun 2024 16:43:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45LGhPke084018; Fri, 21 Jun 2024 16:43:25 GMT (envelope-from git) Date: Fri, 21 Jun 2024 16:43:25 GMT Message-Id: <202406211643.45LGhPke084018@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 681fd2bed8ea - main - pax: Terminate loop for empty directory names 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: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 681fd2bed8eaba88693867ba928a1c03a5b152cc Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=681fd2bed8eaba88693867ba928a1c03a5b152cc commit 681fd2bed8eaba88693867ba928a1c03a5b152cc Author: Ganael Laplanche AuthorDate: 2024-06-21 16:39:09 +0000 Commit: Warner Losh CommitDate: 2024-06-21 16:39:09 +0000 pax: Terminate loop for empty directory names Pax can sometimes loop forever. For example: $ mkdir -p /tmp/src/foo/bar $ rm -rf /tmp/dst ; mkdir -p /tmp/dst $ cd /tmp/src $ echo 'foo/bar/' | /bin/pax -r -w -d -pe "/tmp/dst" Here, pax(1) infinitely deletes and re-creates /tmp/dst/foo/bar/. The problem is that chk_path() (bin/pax/file_subs.c), called from node_creat() also creates the leaf directory when a trailing '/' appears in the directory name to create. When the execution goes back from chk_path() to node_creat(), the function still cannot create the leaf directory (it has been created by chk_path()), so it unlinks it and calls node_creat() again. The function re-creates it, and so on... In node_creat() detect trailing slashes and not create a leaf directory, but only intermediate ones. PR: 277060 Reviewed by: imp --- bin/pax/file_subs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/pax/file_subs.c b/bin/pax/file_subs.c index 7214de337ec4..06602c12db2c 100644 --- a/bin/pax/file_subs.c +++ b/bin/pax/file_subs.c @@ -555,7 +555,12 @@ chk_path( char *name, uid_t st_uid, gid_t st_gid) * work forward from the first / and check each part of the path */ spt = strchr(spt, '/'); - if (spt == NULL) + + /* + * skip creating a leaf dir (with an ending '/') as we only want + * to create parents here + */ + if ((spt == NULL) || (*(spt + 1) == '\0')) break; *spt = '\0';