]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
fixup evaluation of XLAT_CHILD nodes
authorAlan T. DeKok <aland@freeradius.org>
Wed, 8 Apr 2020 21:31:02 +0000 (17:31 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 8 Apr 2020 21:32:34 +0000 (17:32 -0400)
put the result into state->rhead
on resume, merge that result into the parent group

src/lib/unlang/xlat.c
src/lib/unlang/xlat_eval.c

index d818db959d84fcbf844a28fb05b23c4b1562b76b..0bea6356aa1b233a387385fdbb3d501ec2ef3002 100644 (file)
@@ -242,7 +242,6 @@ static unlang_action_t unlang_xlat(REQUEST *request, rlm_rcode_t *presult)
        unlang_frame_state_xlat_t       *state = talloc_get_type_abort(frame->state, unlang_frame_state_xlat_t);
        xlat_exp_t const                *child = NULL;
        xlat_action_t                   xa;
-       fr_value_box_t                  *box;
 
        if (is_repeatable(frame)) {
                xa = xlat_frame_eval_repeat(state->ctx, &state->values, &child,
@@ -282,10 +281,9 @@ static unlang_action_t unlang_xlat(REQUEST *request, rlm_rcode_t *presult)
                 *      The called function can't pass us a value box,
                 *      so we have to create it ourselves.
                 */
-               box = fr_value_box_alloc(state->ctx, FR_TYPE_GROUP, NULL, false);
-               fr_cursor_append(&state->values, box);
+               state->rhead = fr_value_box_alloc(state->ctx, FR_TYPE_GROUP, NULL, false);
 
-               unlang_xlat_push(state->ctx, &box->vb_group, request, child, false);
+               unlang_xlat_push(state->ctx, &state->rhead->vb_group, request, child, false);
                return UNLANG_ACTION_PUSHED_CHILD;
 
        case XLAT_ACTION_YIELD:
index 31f01f1e622d85c208a590a262842e572cea39bd..224969e74783b88d4ac63735647be7696da28fe0 100644 (file)
@@ -906,6 +906,25 @@ xlat_action_t xlat_frame_eval_repeat(TALLOC_CTX *ctx, fr_cursor_t *out,
        }
                break;
 
+       case XLAT_CHILD:
+       {
+               fr_cursor_t from;
+
+               XLAT_DEBUG("** [%i] %s(child) - continuing %%{%s ...}", unlang_interpret_stack_depth(request), __FUNCTION__,
+                          node->fmt);
+
+               rad_assert(*result != NULL);
+
+               xlat_debug_log_expansion(request, *in, NULL);
+               xlat_debug_log_result(request, *result);
+
+               (void) talloc_list_get_type_abort(*result, fr_value_box_t);
+               fr_cursor_init(&from, result);
+               fr_cursor_merge(out, &from);
+               rad_assert(!*result);
+       }
+               break;
+
        default:
                rad_assert(0);
                return XLAT_ACTION_FAIL;
@@ -1078,7 +1097,7 @@ xlat_action_t xlat_frame_eval(TALLOC_CTX *ctx, fr_cursor_t *out, xlat_exp_t cons
                        goto finish;
 
                case XLAT_CHILD:
-                       XLAT_DEBUG("** [%i] %s(child) - %%{%s:...}", unlang_interpret_stack_depth(request), __FUNCTION__,
+                       XLAT_DEBUG("** [%i] %s(child) - %%{%s ...}", unlang_interpret_stack_depth(request), __FUNCTION__,
                                   node->fmt);
 
                        /*