From: Alan T. DeKok Date: Fri, 7 Mar 2025 14:18:39 +0000 (-0500) Subject: rename function to be clearer, and check for errors X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f6f275a6c3c4671e64bde16c2cca2102eff04b3;p=thirdparty%2Ffreeradius-server.git rename function to be clearer, and check for errors --- diff --git a/src/bin/unit_test_attribute.c b/src/bin/unit_test_attribute.c index 8f7df15f5a..2a5e844dc5 100644 --- a/src/bin/unit_test_attribute.c +++ b/src/bin/unit_test_attribute.c @@ -2995,7 +2995,7 @@ static size_t command_xlat_argv(command_result_t *result, command_file_ctx_t *cc RETURN_OK_WITH_ERROR(); } - argc = xlat_flatten_compiled_argv(cc->tmp_ctx, &argv, head); + argc = xlat_flatten_to_argv(cc->tmp_ctx, &argv, head); if (argc <= 0) { fr_strerror_printf_push("ERROR in argument %d", (int) -argc); RETURN_OK_WITH_ERROR(); diff --git a/src/lib/unlang/xlat.h b/src/lib/unlang/xlat.h index 152c6059f1..3d7ef44160 100644 --- a/src/lib/unlang/xlat.h +++ b/src/lib/unlang/xlat.h @@ -396,7 +396,7 @@ ssize_t xlat_aeval_compiled(TALLOC_CTX *ctx, char **out, request_t *request, xlat_exp_head_t const *head, xlat_escape_legacy_t escape, void const *escape_ctx) CC_HINT(nonnull (2, 3, 4)); -int xlat_flatten_compiled_argv(TALLOC_CTX *ctx, xlat_exp_head_t ***argv, xlat_exp_head_t *head); +int xlat_flatten_to_argv(TALLOC_CTX *ctx, xlat_exp_head_t ***argv, xlat_exp_head_t *head); fr_slen_t xlat_tokenize_expression(TALLOC_CTX *ctx, xlat_exp_head_t **head, fr_sbuff_t *in, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules); diff --git a/src/lib/unlang/xlat_eval.c b/src/lib/unlang/xlat_eval.c index 293e1cec83..92163c7dee 100644 --- a/src/lib/unlang/xlat_eval.c +++ b/src/lib/unlang/xlat_eval.c @@ -1573,16 +1573,21 @@ ssize_t xlat_aeval_compiled(TALLOC_CTX *ctx, char **out, request_t *request, } -/** Turn xlat_tokenize_argv() into an argv[] array, and nuke the input list. +/** Turn am xlat list into an argv[] array, and nuke the input list. * * This is mostly for async use. */ -int xlat_flatten_compiled_argv(TALLOC_CTX *ctx, xlat_exp_head_t ***argv, xlat_exp_head_t *head) +int xlat_flatten_to_argv(TALLOC_CTX *ctx, xlat_exp_head_t ***argv, xlat_exp_head_t *head) { int i; xlat_exp_head_t **my_argv; size_t count; + if (head->flags.needs_resolving) { + fr_strerror_printf("Cannot flatten expression with unresolved functions"); + return -1; + } + count = 0; xlat_exp_foreach(head, node) { count++; diff --git a/src/lib/unlang/xlat_expr.c b/src/lib/unlang/xlat_expr.c index 7ef14b93a5..b5b4d40e67 100644 --- a/src/lib/unlang/xlat_expr.c +++ b/src/lib/unlang/xlat_expr.c @@ -1296,7 +1296,7 @@ static int xlat_instantiate_logical(xlat_inst_ctx_t const *xctx) { xlat_logical_inst_t *inst = talloc_get_type_abort(xctx->inst, xlat_logical_inst_t); - inst->argc = xlat_flatten_compiled_argv(inst, &inst->argv, xctx->ex->call.args); + inst->argc = xlat_flatten_to_argv(inst, &inst->argv, xctx->ex->call.args); if (xctx->ex->call.func->token == T_LOR) { inst->callback = xlat_logical_or_resume; inst->stop_on_match = true;