]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
rand, etc. aren't pure
authorAlan T. DeKok <aland@freeradius.org>
Thu, 25 Nov 2021 02:17:17 +0000 (21:17 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 25 Nov 2021 16:21:09 +0000 (11:21 -0500)
src/lib/unlang/xlat_builtin.c

index 364c809396e43997d80ef85ab5fc8d88846d8fde..16ae347f31cbb8a6e58d86a3a7f40861d02b7464 100644 (file)
@@ -3396,8 +3396,6 @@ do { \
        XLAT_REGISTER_MONO("md4", xlat_func_md4, xlat_func_md4_arg);
        XLAT_REGISTER_MONO("md5", xlat_func_md5, xlat_func_md5_arg);
        XLAT_REGISTER_MONO("pack", xlat_func_pack, xlat_func_pack_arg);
-       XLAT_REGISTER_MONO("rand", xlat_func_rand, xlat_func_rand_arg);
-       XLAT_REGISTER_MONO("randstr", xlat_func_randstr, xlat_func_randstr_arg);
 #if defined(HAVE_REGEX_PCRE) || defined(HAVE_REGEX_PCRE2)
        xlat_register(NULL, "regex", xlat_func_regex, NULL);
 #endif
@@ -3427,6 +3425,16 @@ do { \
        XLAT_REGISTER_MONO("urlquote", xlat_func_urlquote, xlat_func_urlquote_arg);
        XLAT_REGISTER_MONO("urlunquote", xlat_func_urlunquote, xlat_func_urlunquote_arg);
 
+#undef XLAT_REGISTER_MONO
+#define XLAT_REGISTER_MONO(_xlat, _func, _arg) \
+do { \
+       if (!(xlat = xlat_register(NULL, _xlat, _func, NULL))) return -1; \
+       xlat_func_mono(xlat, &_arg); \
+} while (0)
+
+       XLAT_REGISTER_MONO("rand", xlat_func_rand, xlat_func_rand_arg);
+       XLAT_REGISTER_MONO("randstr", xlat_func_randstr, xlat_func_randstr_arg);
+
        xlat_register(NULL, "module", xlat_func_module, NULL);
 
        return 0;