]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
remove last vestige of %string(...)
authorAlan T. DeKok <aland@freeradius.org>
Mon, 11 Dec 2023 19:58:13 +0000 (14:58 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 11 Dec 2023 20:00:00 +0000 (15:00 -0500)
and correct the filter_password policy so that it works

raddb/policy.d/filter
src/tests/keywords/filter_password [new file with mode: 0644]

index d4631c2dd7e84716d73c48e81e7af1a0f39e55af..54441a3e28ad97ad5ee7429bf02866a89975a460 100644 (file)
@@ -118,12 +118,18 @@ filter_username {
 #  This policy filters them out.
 #
 filter_password {
-       if (&User-Password && \
-          (&User-Password != "%string(User-Password)")) {
-               string tmp
-               &tmp := %string(User-Password)
-               &request.User-Password := %string(tmp)
-        }
+       if &User-Password {
+               group tmp
+               octets delim
+
+               #
+               #  Because "\000" yields "zero length delimiter is not allowed"
+               #
+               &delim = 0x00
+               &tmp.User-Password := %explode(%{User-Password}, "%{delim}")
+
+               &User-Password := &tmp.User-Password[0]
+       }
 }
 
 filter_inner_identity {
diff --git a/src/tests/keywords/filter_password b/src/tests/keywords/filter_password
new file mode 100644 (file)
index 0000000..1c2c07a
--- /dev/null
@@ -0,0 +1,31 @@
+#
+# Tests for NUL in the middle of a string
+#
+
+&Reply-Message := "bob\000hello"
+
+#
+#  Commented out because it fails
+#
+#if %length("\000") != 1 {
+#      test_fail
+#}
+
+if &Reply-Message {
+       group tmp
+       octets delim
+
+       #
+       #  Because "\000" yields "zero length delimiter is not allowed"
+       #
+       &delim = 0x00
+       &tmp.Reply-Message := %explode(%{Reply-Message}, "%{delim}")
+
+       &Reply-Message := &tmp.Reply-Message[0]
+}
+
+if &Reply-Message != "bob" {
+       test_fail
+}
+
+success