Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Apr 2006 12:53:45 +0200
From:      Daniel Hartmeier <daniel@benzedrine.cx>
To:        Boris Polevoy <vapcom@mail.ru>
Cc:        mlaier@freebsd.org, pf@benzedrine.cx, freebsd-pf@freebsd.org
Subject:   Re: PF with subanchors possible bug
Message-ID:  <20060428105345.GM19449@insomnia.benzedrine.cx>
In-Reply-To: <20060428103529.GL19449@insomnia.benzedrine.cx>
References:  <E1FZOYH-0002ho-00.vapcom-mail-ru@f22.mail.ru> <20060428103529.GL19449@insomnia.benzedrine.cx>

next in thread | previous in thread | raw e-mail | index | archive | help
The second bug is is userland pfctl, I suggest

Index: parse.y
===================================================================
RCS file: /cvs/src/sbin/pfctl/parse.y,v
retrieving revision 1.496
diff -u -r1.496 parse.y
--- parse.y	6 Apr 2006 21:54:56 -0000	1.496
+++ parse.y	28 Apr 2006 10:54:52 -0000
@@ -733,7 +733,7 @@
 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);
@@ -742,8 +742,13 @@
 			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");
 
With both this and your patch applied, your example behaves as I expect
it should. I hope you agree ;)

Daniel



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060428105345.GM19449>