summaryrefslogtreecommitdiff
path: root/sbin/pfctl
diff options
context:
space:
mode:
authorChristian Weisgerber <naddy@cvs.openbsd.org>2020-10-14 19:30:38 +0000
committerChristian Weisgerber <naddy@cvs.openbsd.org>2020-10-14 19:30:38 +0000
commit71862d8891135e5b811b19337b6a9628339b497c (patch)
tree561569ef8efaae348ef9d77b9053ac09749c44ae /sbin/pfctl
parent463f266f080fff39e2821ba2b660e3d0e1630aad (diff)
Accommodate a basename(3) that takes a non-const parameter and may
in fact modify the string buffer. ok kn@ sashan@ cVS: ----------------------------------------------------------------------
Diffstat (limited to 'sbin/pfctl')
-rw-r--r--sbin/pfctl/pfctl.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c
index e01087586c7..3441d47aaca 100644
--- a/sbin/pfctl/pfctl.c
+++ b/sbin/pfctl/pfctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfctl.c,v 1.382 2020/01/16 01:02:20 kn Exp $ */
+/* $OpenBSD: pfctl.c,v 1.383 2020/10/14 19:30:37 naddy Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -2241,16 +2241,19 @@ 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));
}