]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
don't create too many random things
authorAlan T. DeKok <aland@freeradius.org>
Mon, 20 May 2024 15:07:54 +0000 (11:07 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 20 May 2024 17:37:51 +0000 (13:37 -0400)
src/modules/rlm_expr/rlm_expr.c
src/tests/keywords/randstr [new file with mode: 0644]

index 1aad02d62d01b819bb27a85f450a48c470b4be90..c5ebd34455283b23122fc6555755c5383c5f95d8 100644 (file)
@@ -681,7 +681,7 @@ static ssize_t randstr_xlat(UNUSED void *instance, UNUSED REQUEST *request,
                        return -1;
                }
 
-               if (number > 0) {
+               if (number > 1) {
                        number--;
                        goto redo;
                }
diff --git a/src/tests/keywords/randstr b/src/tests/keywords/randstr
new file mode 100644 (file)
index 0000000..6884cb0
--- /dev/null
@@ -0,0 +1,16 @@
+update request {
+       &Tmp-Octets-0 := "0x%{randstr:16h}"
+       &Tmp-String-0 := "%{randstr:16h}"
+}
+
+if ("%{length:Tmp-Octets-0}" == 16) {
+       update reply {
+                       Filter-Id := "filter"
+       }
+}
+
+if ("%{length:Tmp-String-0}" == 32) {
+       update reply {
+                       Filter-Id := "filter"
+       }
+}