]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
set more flags correctly
authorAlan T. DeKok <aland@freeradius.org>
Wed, 13 Jul 2022 20:13:24 +0000 (16:13 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 14 Jul 2022 14:04:02 +0000 (10:04 -0400)
src/lib/unlang/xlat_expr.c
src/lib/unlang/xlat_tokenize.c

index 2dec4df402345aa8073f44d3f8a88b04c343a2bf..0b6f0671de6e79d49c92ae0c5a56bf02514c4961 100644 (file)
@@ -153,7 +153,6 @@ static int xlat_expr_resolve_binary(xlat_exp_t *node, UNUSED void *inst, xlat_re
                        XLAT_DEBUG("\tresolve attr a\n");
                        if (tmpl_resolve(a->vpt, &my_tr_rules) < 0) return -1;
                        a->flags.needs_resolving = false;
-                       arg1->flags = a->flags;
                }
 
                my_tr_rules.enumv = tmpl_da(a->vpt);
@@ -163,7 +162,6 @@ static int xlat_expr_resolve_binary(xlat_exp_t *node, UNUSED void *inst, xlat_re
 
                b->flags.needs_resolving = false;
                b->flags.pure = tmpl_is_data(b->vpt);
-               arg2->flags = b->flags;
                goto flags;
        }
 
@@ -175,7 +173,6 @@ static int xlat_expr_resolve_binary(xlat_exp_t *node, UNUSED void *inst, xlat_re
                        if (tmpl_resolve(b->vpt, &my_tr_rules) < 0) return -1;
 
                        b->flags.needs_resolving = false;
-                       arg2->flags = b->flags;
                }
 
                my_tr_rules.enumv = tmpl_da(b->vpt);
@@ -185,20 +182,27 @@ static int xlat_expr_resolve_binary(xlat_exp_t *node, UNUSED void *inst, xlat_re
 
                a->flags.needs_resolving = false;
                a->flags.pure = tmpl_is_data(b->vpt);
-               arg1->flags = a->flags;
-
                goto flags;
        }
 
 resolve:
-       if (xlat_resolve(node->call.args, xr_rules) < 0) return -1;
+       /*
+        *      This call will fix everything recursively.
+        */
+       return xlat_resolve(node->call.args, xr_rules);
 
 flags:
-       node->flags = node->call.func->flags;
-       node->call.args->flags.needs_resolving = false;
-       xlat_flags_merge(&node->flags, &node->call.args->flags);
+       arg1->flags = arg1->group->flags = a->flags;
+       arg2->flags = arg2->group->flags = b->flags;
+       xlat_flags_merge(&node->call.args->flags, &arg2->flags);
+
+       fr_assert(!a->flags.needs_resolving);
+       fr_assert(!b->flags.needs_resolving);
 
-       node->flags.can_purify = (node->call.func->flags.pure && node->call.args->flags.pure) | node->call.args->flags.can_purify;
+       fr_assert(!arg1->flags.needs_resolving);
+       fr_assert(!arg2->flags.needs_resolving);
+
+       node->call.args->flags.needs_resolving = false;
 
        return 0;
 }
@@ -2021,7 +2025,6 @@ static ssize_t tokenize_regex_rhs(xlat_exp_head_t *head, xlat_exp_t **out, fr_sb
 
        node->flags.pure = !tmpl_contains_xlat(node->vpt);
        node->flags.needs_resolving = tmpl_needs_resolving(node->vpt);
-       xlat_flags_merge(&head->flags, &node->flags);
 
        *out = node;
 
index ca260904c92e7d8fae709326b67bb6524e0152c3..558a6a55c4aaef48ea543a6ff359bfff062040f2 100644 (file)
@@ -1811,6 +1811,8 @@ int xlat_resolve(xlat_exp_head_t *head, xlat_res_rules_t const *xr_rules)
                 *      A resolved function with unresolved args
                 */
                case XLAT_FUNC:
+                       node->flags = node->call.func->flags;
+
                        if (node->call.func->resolve) {
                                void *inst = node->call.inst ? node->call.inst->data : NULL;
 
@@ -1819,9 +1821,7 @@ int xlat_resolve(xlat_exp_head_t *head, xlat_res_rules_t const *xr_rules)
                                if (xlat_resolve(node->call.args, xr_rules) < 0) return -1;
                        }
 
-                       node->flags = node->call.func->flags;
                        xlat_flags_merge(&node->flags, &node->call.args->flags);
-
                        node->flags.can_purify = (node->call.func->flags.pure && node->call.args->flags.pure) | node->call.args->flags.can_purify;
                        break;