pfctl fails to load certain configuration. I have reduced the sample configuration as follows (does not make sense now, but demonstrates the problem): export MALLOC_CONF=junk:true pfctl -n -f - <<EOF rdr on em0 proto tcp from any to any -> 1.1.1.1 port 2121 pass out log quick on lo0 route-to lo0 from any to any pass in log quick on lo0 route-to (lo0 localhost) from any to any EOF produces: pfctl: expand_rule: strlcpy This behavior seems to appear in FreeBSD 11.2 (the error did not display in FreeBSD 11.1). Pavel Rydvan
Can you test this patch? diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y index 3b1f0bbea3d..c542bf72f70 100644 --- a/sbin/pfctl/parse.y +++ b/sbin/pfctl/parse.y @@ -4408,7 +4408,7 @@ route_host : STRING { $$ = calloc(1, sizeof(struct node_host)); if ($$ == NULL) err(1, "route_host: calloc"); - $$->ifname = $1; + $$->ifname = strdup($1); set_ipmask($$, 128); $$->next = NULL; $$->tail = $$; @@ -4418,7 +4418,7 @@ route_host : STRING { $$ = $3; for (n = $3; n != NULL; n = n->next) - n->ifname = $2; + n->ifname = strdup($2); } ;
(In reply to Kristof Provost from comment #1) Yes, this helps. Thanks! Pavel
A commit references this bug: Author: kp Date: Sat Oct 20 18:11:47 UTC 2018 New revision: 339464 URL: https://svnweb.freebsd.org/changeset/base/339464 Log: pfctl: Dup strings When we set the ifname we have to copy the string, rather than just keep the pointer. PR: 231323 MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D17507 Changes: head/sbin/pfctl/parse.y
A commit references this bug: Author: kp Date: Sat Oct 20 18:18:29 UTC 2018 New revision: 339466 URL: https://svnweb.freebsd.org/changeset/base/339466 Log: pfctl tests: Basic test case for PR 231323 PR: 231323 MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D17508 Changes: head/sbin/pfctl/tests/files/pf1005.in head/sbin/pfctl/tests/files/pf1005.ok head/sbin/pfctl/tests/files/pfctl_test_descr.sh head/sbin/pfctl/tests/pfctl_test.sh
A commit references this bug: Author: kp Date: Sun Nov 18 09:47:30 UTC 2018 New revision: 340549 URL: https://svnweb.freebsd.org/changeset/base/340549 Log: MFC r339464: pfctl: Dup strings When we set the ifname we have to copy the string, rather than just keep the pointer. PR: 231323 Changes: _U stable/12/ stable/12/sbin/pfctl/parse.y
A commit references this bug: Author: kp Date: Sun Nov 18 09:47:40 UTC 2018 New revision: 340550 URL: https://svnweb.freebsd.org/changeset/base/340550 Log: MFC r339464: pfctl: Dup strings When we set the ifname we have to copy the string, rather than just keep the pointer. PR: 231323 Changes: _U stable/11/ stable/11/sbin/pfctl/parse.y
A commit references this bug: Author: kp Date: Sun Nov 18 09:48:52 UTC 2018 New revision: 340551 URL: https://svnweb.freebsd.org/changeset/base/340551 Log: MFC r339466: pfctl tests: Basic test case for PR 231323 PR: 231323 Changes: _U stable/12/ stable/12/sbin/pfctl/tests/files/pf1005.in stable/12/sbin/pfctl/tests/files/pf1005.ok stable/12/sbin/pfctl/tests/files/pfctl_test_descr.sh stable/12/sbin/pfctl/tests/pfctl_test.sh