From: Alan T. DeKok Date: Wed, 8 Apr 2020 21:31:02 +0000 (-0400) Subject: fixup evaluation of XLAT_CHILD nodes X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=84dd06d35f8b1ebbd645d968571f0b332e2f0fd4;p=thirdparty%2Ffreeradius-server.git fixup evaluation of XLAT_CHILD nodes put the result into state->rhead on resume, merge that result into the parent group --- diff --git a/src/lib/unlang/xlat.c b/src/lib/unlang/xlat.c index d818db959d8..0bea6356aa1 100644 --- a/src/lib/unlang/xlat.c +++ b/src/lib/unlang/xlat.c @@ -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: diff --git a/src/lib/unlang/xlat_eval.c b/src/lib/unlang/xlat_eval.c index 31f01f1e622..224969e7478 100644 --- a/src/lib/unlang/xlat_eval.c +++ b/src/lib/unlang/xlat_eval.c @@ -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); /*