From: Alan T. DeKok Date: Mon, 24 Mar 2025 12:04:40 +0000 (+0200) Subject: respect casting in tmpl_to_atype() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a45b373da860081720a5547e720f2ef5b11958b;p=thirdparty%2Ffreeradius-server.git respect casting in tmpl_to_atype() the output might be a value-box, but it should have the data type specified by the tmpl, and not by the input data --- diff --git a/src/lib/server/tmpl_eval.c b/src/lib/server/tmpl_eval.c index ab5152e095c..f35ecce3a28 100644 --- a/src/lib/server/tmpl_eval.c +++ b/src/lib/server/tmpl_eval.c @@ -712,10 +712,17 @@ ssize_t _tmpl_to_atype(TALLOC_CTX *ctx, void *out, */ if (dst_type == FR_TYPE_VALUE_BOX) { fr_value_box_t **vb_out = (fr_value_box_t **)out; + fr_type_t cast_type; MEM(*vb_out = fr_value_box_alloc_null(ctx)); - ret = needs_dup ? fr_value_box_copy(*vb_out, *vb_out, to_cast) : fr_value_box_steal(*vb_out, *vb_out, to_cast); + cast_type = tmpl_rules_cast(vpt); + if (cast_type == FR_TYPE_NULL) { + ret = needs_dup ? fr_value_box_copy(*vb_out, *vb_out, to_cast) : fr_value_box_steal(*vb_out, *vb_out, to_cast); + } else { + ret = fr_value_box_cast(ctx, *vb_out, cast_type, NULL, to_cast); + } + talloc_free(tmp_ctx); if (ret < 0) { RPEDEBUG("Failed copying data to output box");