PF with subanchors possible bug

Daniel Hartmeier daniel at benzedrine.cx
Fri Apr 28 10:53:49 UTC 2006


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


More information about the freebsd-pf mailing list