From nobody Tue Jul 15 10:07:49 2025 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 4bhFHV1lRQz62DbC; Tue, 15 Jul 2025 10:07:50 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bhFHT5gh3z3f2d; Tue, 15 Jul 2025 10:07:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1752574069; 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=25qTEr8sxkUN6LJQ13C6x0zwK2y9XGZSTvueZJr+SwU=; b=A9cEHsqc2DzN1SrznPQQnfhCLUjSMaTyj5FXHcrWxW3fqwLdBpZ6yldklc6PRyT/TDzJIw wliJxLYms11Vo7hquMJ1XeZVFPiAJRWRSEhifSCGsX7148fIQh8/6/Sj56n0Ad4jsj5oPq MyUgWcpd0lRq+o9i8kNY6p5IshC1H8yq93yMksm/sZdLZdpSdBx0CRwtzMMZABQkPlZH/H ANCwMV6NJdMKmqdAQc6FD4Jh4vlIZWi5iZ5GvyDjbrnWwxq200rABZsrdeaSDmRXaMUQMZ 32s7kqAA+H9Ii1itz2Hg4OzILWgKmwcjccGZAJ839NBeDWll+oHRWqPmqyQN0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1752574069; 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=25qTEr8sxkUN6LJQ13C6x0zwK2y9XGZSTvueZJr+SwU=; b=M4e283Gp7jJ126UnK5eNDDazmUj8X2gNSlKzYsB6T9rpBu2DSYQj5xA+zAoxhDE/ZTmMir U/A2+0GK9sVWUgGWYtF9908q+ypQoNYk4ifxRuZj/olwEtlYGnGCkvCi6zkrgp4dpYToeM EMog6rv2vHmTwVND7UFdvzXle67zEywEUTL6RXLHRVRRiEp5wf/gDIS52PPGe6Un+AnJ7D oAR9v8hGZRJ+l/cXRi1qzYdKIlfsTaBqarZ4s+gDvnat/VaR1RUOQIuQXrA30oQ635MarN uDyoAtOeosFfIC93dz0sRcy37NyTgXpOEAv8ZB9nWNtQ8cdwCsWo3ly5N3/COw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1752574069; a=rsa-sha256; cv=none; b=NPf1QxbYXfFxozgnzoS/WHsjzv6eZAc6ZJXJ0ClcYiU2qRXuYCLz5VKq3gTzvFdJGTDdA2 a/j3oAxFNjhtHN5nRblDvMa4jx9V4GsPC5rP9I4olNeTdGTIwWVtnenOBnnX/XCKQneYyx j8jSt2nzttHKWlfxtsJB5M0TtF6c29pFBBKmCyE0ZSKCq65fDQq/3ndqjye7GT90EOXshr b9oL39SDOQN3qyGiMhN7VeAAt6BIfsflTuwpRY3C2Agwm0IHoDCSJjjbPuIn0HmO58pGmp tayUQQyClR8sbHx5IwDi9yr9LAn5XHdVDXfOxu0WZ6YQuNz7VD0tjFj1ncBxrQ== 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 4bhFHT5GMvzbbm; Tue, 15 Jul 2025 10:07:49 +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 56FA7n6h027769; Tue, 15 Jul 2025 10:07:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 56FA7nDK027766; Tue, 15 Jul 2025 10:07:49 GMT (envelope-from git) Date: Tue, 15 Jul 2025 10:07:49 GMT Message-Id: <202507151007.56FA7nDK027766@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: d217ed397922 - main - pfctl: Accommodate a basename(3) that takes a non-const parameter 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: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d217ed397922fb369fa22023d844aa9cda127b0a Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=d217ed397922fb369fa22023d844aa9cda127b0a commit d217ed397922fb369fa22023d844aa9cda127b0a Author: Kristof Provost AuthorDate: 2025-07-07 14:39:08 +0000 Commit: Kristof Provost CommitDate: 2025-07-15 07:55:28 +0000 pfctl: Accommodate a basename(3) that takes a non-const parameter It may in fact modify the string buffer. ok kn@ sashan@ Obtained from: OpenBSD, naddy , 697265c5fb Sponsored by: Rubicon Communications, LLC ("Netgate") --- sbin/pfctl/pfctl.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 271286deeda7..2015e0a09549 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -131,8 +131,8 @@ int pfctl_walk_get(int, struct pfioc_ruleset *, void *); int pfctl_walk_anchors(int, int, const char *, int(*)(int, struct pfioc_ruleset *, void *), void *); struct pfr_anchors * - pfctl_get_anchors(int, char *, int); -int pfctl_recurse(int, int, char *, + pfctl_get_anchors(int, const char *, int); +int pfctl_recurse(int, int, const char *, int(*)(int, int, struct pfr_anchoritem *)); int pfctl_call_clearrules(int, int, struct pfr_anchoritem *); int pfctl_call_cleartables(int, int, struct pfr_anchoritem *); @@ -2988,20 +2988,23 @@ pfctl_show_anchors(int dev, int opts, char *anchor) } struct pfr_anchors * -pfctl_get_anchors(int dev, char *anchor, int opts) +pfctl_get_anchors(int dev, const char *anchor, int opts) { struct pfioc_ruleset pr; static struct pfr_anchors anchors; + char anchorbuf[PATH_MAX]; char *n; SLIST_INIT(&anchors); memset(&pr, 0, sizeof(pr)); if (*anchor != '\0') { - n = dirname(anchor); + strlcpy(anchorbuf, anchor, sizeof(anchorbuf)); + n = dirname(anchorbuf); if (n[0] != '.' && n[1] != '\0') strlcpy(pr.path, n, sizeof(pr.path)); - n = basename(anchor); + strlcpy(anchorbuf, anchor, sizeof(anchorbuf)); + n = basename(anchorbuf); if (n != NULL) strlcpy(pr.name, n, sizeof(pr.name)); } @@ -3051,7 +3054,7 @@ pfctl_call_clearanchors(int dev, int opts, struct pfr_anchoritem *pfra) } int -pfctl_recurse(int dev, int opts, char *anchorname, +pfctl_recurse(int dev, int opts, const char *anchorname, int(*walkf)(int, int, struct pfr_anchoritem *)) { int rv = 0;