]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
simply omit optional arguments, rather than making them FR_TYPE_NULL
authorAlan T. DeKok <aland@freeradius.org>
Fri, 3 Jun 2022 22:29:49 +0000 (18:29 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 6 Jun 2022 20:28:15 +0000 (16:28 -0400)
We want FR_TYPE_NULL to mean something else, and we don't want to
use it as a normal result.

src/lib/unlang/xlat_builtin.c
src/lib/unlang/xlat_eval.c

index a8ef02f6b71fe21b1b680138ae959f20d50856ee..0dac2b39fb07bf58602b080f76197ee333de5cfe 100644 (file)
@@ -1668,7 +1668,7 @@ static xlat_action_t xlat_func_lpad(UNUSED TALLOC_CTX *ctx, fr_dcursor_t *out,
        /*
         *      Fill is optional
         */
-       if (fill->type != FR_TYPE_NULL) {
+       if (fill) {
                fill_str = fill->vb_strvalue;
                fill_len = talloc_array_length(fill_str) - 1;
        }
@@ -1756,7 +1756,7 @@ static xlat_action_t xlat_func_rpad(UNUSED TALLOC_CTX *ctx, fr_dcursor_t *out,
        /*
         *      Fill is optional
         */
-       if (fill->type != FR_TYPE_NULL) {
+       if (fill) {
                fill_str = fill->vb_strvalue;
                fill_len = talloc_array_length(fill_str) - 1;
        }
index ab0029864a8e2d0a3b68b76f1b7ed6074763a58a..dbb4a162b7edc2fab19e498209e4b3b03d49c8c3 100644 (file)
@@ -415,10 +415,9 @@ xlat_action_t xlat_process_args(TALLOC_CTX *ctx, fr_value_box_list_t *list, requ
                                }
 
                                /*
-                                *      Add a placeholder 'null' box
+                                *      The argument isn't required.  Just omit it.  xlat_func_args() enforces
+                                *      that optional arguments are at the end of the argument list.
                                 */
-                               MEM(vb = fr_value_box_alloc(ctx, FR_TYPE_NULL, NULL, false));
-                               fr_dlist_insert_tail(list, vb);
                                return XLAT_ACTION_DONE;
                        }