]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
respect casting in tmpl_to_atype()
authorAlan T. DeKok <aland@freeradius.org>
Mon, 24 Mar 2025 12:04:40 +0000 (14:04 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 25 Mar 2025 12:17:47 +0000 (08:17 -0400)
the output might be a value-box, but it should have the data type
specified by the tmpl, and not by the input data

src/lib/server/tmpl_eval.c

index ab5152e095c51c25b78b31bc11ed63fe8f2bba73..f35ecce3a287957d4ee4c6f18bebab7c5712b3de 100644 (file)
@@ -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");