Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178257561
D61409.1796348748.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D61409.1796348748.diff
View Options
diff --git a/sys/netpfil/pf/pf_table.c b/sys/netpfil/pf/pf_table.c
--- a/sys/netpfil/pf/pf_table.c
+++ b/sys/netpfil/pf/pf_table.c
@@ -1895,6 +1895,13 @@
for (i = strlen(anchor); i < siz; i++)
if (anchor[i])
return (-1);
+ /*
+ * Ruleset paths have no empty components. A table anchor with one
+ * would not match the path of the ruleset the table is attached to.
+ */
+ if (strstr(anchor, "//") != NULL ||
+ (anchor[0] != '\0' && anchor[strlen(anchor) - 1] == '/'))
+ return (-1);
return (0);
}
diff --git a/tests/sys/netpfil/pf/table.sh b/tests/sys/netpfil/pf/table.sh
--- a/tests/sys/netpfil/pf/table.sh
+++ b/tests/sys/netpfil/pf/table.sh
@@ -619,6 +619,37 @@
pft_cleanup
}
+atf_test_case "anchor_slash" "cleanup"
+anchor_slash_head()
+{
+ atf_set descr 'Test tables in anchors with empty path components'
+ atf_set require.user root
+}
+
+anchor_slash_body()
+{
+ pft_init
+
+ atf_check -s exit:0 -e ignore \
+ pfctl -a foo/bar -t t1 -T add 192.0.2.1
+ atf_check -s exit:0 -e ignore -o match:"192.0.2.1" \
+ pfctl -a /foo/bar -t t1 -T show
+
+ atf_check -s not-exit:0 -e ignore \
+ pfctl -a foo/bar/ -t t2 -T add 192.0.2.2
+ atf_check -s not-exit:0 -e ignore \
+ pfctl -a foo//bar -t t3 -T add 192.0.2.3
+
+ # Used to trip the corruption check in pfr_get_tables()
+ atf_check -s exit:0 -e ignore -o inline:"t1@foo/bar\n" \
+ pfctl -a foo/bar -sT
+}
+
+anchor_slash_cleanup()
+{
+ pft_cleanup
+}
+
atf_test_case "flush" "cleanup"
flush_head()
{
@@ -1156,6 +1187,7 @@
atf_add_test_case "pr259689"
atf_add_test_case "precreate"
atf_add_test_case "anchor"
+ atf_add_test_case "anchor_slash"
atf_add_test_case "flush"
atf_add_test_case "large"
atf_add_test_case "show_recursive"
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 4, 1:45 AM (18 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42190507
Default Alt Text
D61409.1796348748.diff (1 KB)
Attached To
Mode
D61409: pf: reject table anchors with empty path components
Attached
Detach File
Event Timeline