]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
rename function to be clearer, and check for errors
authorAlan T. DeKok <aland@freeradius.org>
Fri, 7 Mar 2025 14:18:39 +0000 (09:18 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 7 Mar 2025 15:43:07 +0000 (10:43 -0500)
src/bin/unit_test_attribute.c
src/lib/unlang/xlat.h
src/lib/unlang/xlat_eval.c
src/lib/unlang/xlat_expr.c

index 8f7df15f5a5e9b0f6e0222eed6d4400f5a234e7a..2a5e844dc566b5ea7c328e602c766c940e7a2601 100644 (file)
@@ -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();
index 152c6059f1c31f9d071777fdf7d8cdab483170c3..3d7ef441605c4f4ab401f2b431a4c5b021dbeec6 100644 (file)
@@ -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);
index 293e1cec835583d780c25f0e9cab0f1eea1dd6ed..92163c7deed601afa0c4fda341f16971746988fb 100644 (file)
@@ -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++;
index 7ef14b93a5a03da51fb50ac97b1f12979fd5545b..b5b4d40e671e24dee43ba3b153b723d7aeddaa14 100644 (file)
@@ -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;