From b6ac2ce97f6f535631a64408c6e4a79f3f59b8da Mon Sep 17 00:00:00 2001 From: Daniel Hartmeier Date: Tue, 2 May 2006 10:08:46 +0000 Subject: fix creation of sub-anchors, e.g. if you create an anchor /foo/bar, create only bar under foo, not /bar as well. secondly, when using "load anchor from" from a sub-anchor, the loading point should be relative to the sub-anchor doing the load (unless absolute paths are used, of course). from Boris Polevoy. probably a -stable candidate. --- sbin/pfctl/parse.y | 13 +++++++++---- sys/net/pf_table.c | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index 0db2fec3a08..26622df74e6 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.497 2006/05/01 12:24:32 dhartmei Exp $ */ +/* $OpenBSD: parse.y,v 1.498 2006/05/02 10:08:45 dhartmei Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. @@ -734,7 +734,7 @@ anchorrule : ANCHOR string dir interface af proto fromto filter_opts { loadrule : LOAD ANCHOR string FROM string { struct loadanchors *loadanchor; - if (strlen($3) >= MAXPATHLEN) { + if (strlen(pf->anchor) + 1 + strlen($3) >= MAXPATHLEN) { yyerror("anchorname %s too long, max %u\n", $3, MAXPATHLEN - 1); free($3); @@ -743,8 +743,13 @@ loadrule : LOAD ANCHOR string FROM string { loadanchor = calloc(1, sizeof(struct loadanchors)); if (loadanchor == NULL) err(1, "loadrule: calloc"); - if ((loadanchor->anchorname = strdup($3)) == NULL) - err(1, "loadrule: strdup"); + if ((loadanchor->anchorname = malloc(MAXPATHLEN)) == NULL) + err(1, "loadrule: malloc"); + if (pf->anchor[0]) + snprintf(loadanchor->anchorname, MAXPATHLEN, "%s/%s", + pf->anchor, $3); + else + strlcpy(loadanchor->anchorname, $3, MAXPATHLEN); if ((loadanchor->filename = strdup($5)) == NULL) err(1, "loadrule: strdup"); diff --git a/sys/net/pf_table.c b/sys/net/pf_table.c index ca6eb2aef55..a79ed372a44 100644 --- a/sys/net/pf_table.c +++ b/sys/net/pf_table.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf_table.c,v 1.67 2005/08/02 12:40:42 pascoe Exp $ */ +/* $OpenBSD: pf_table.c,v 1.68 2006/05/02 10:08:45 dhartmei Exp $ */ /* * Copyright (c) 2002 Cedric Berger @@ -2049,7 +2049,7 @@ pfr_attach_table(struct pf_ruleset *rs, char *name) bzero(&tbl, sizeof(tbl)); strlcpy(tbl.pfrt_name, name, sizeof(tbl.pfrt_name)); if (ac != NULL) - strlcpy(tbl.pfrt_anchor, ac->name, sizeof(tbl.pfrt_anchor)); + strlcpy(tbl.pfrt_anchor, ac->path, sizeof(tbl.pfrt_anchor)); kt = pfr_lookup_table(&tbl); if (kt == NULL) { kt = pfr_create_ktable(&tbl, time_second, 1); -- cgit v1.2.3