]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
is RHS of struct assignment is xlat, cast it to a string
authorAlan T. DeKok <aland@freeradius.org>
Sat, 23 Dec 2023 19:48:55 +0000 (14:48 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 23 Dec 2023 19:48:55 +0000 (14:48 -0500)
so that radius_legacy_map_apply() doesn't have to do much else

src/lib/server/map.c

index a7da438b5e3c07400b41aa256910476910d776f4..dd3714fe10e892516dec883e55526cde040b0fbd 100644 (file)
@@ -747,6 +747,13 @@ check_for_child:
 
        if (parent_p) *parent_p = parent;
 
+       /*
+        *      Xlat expansions are cast to strings for structural data types.
+        */
+       if (tmpl_attr_tail_da_is_structural(map->lhs) && (tmpl_is_xlat(map->rhs))) {
+               tmpl_cast_set(map->rhs, FR_TYPE_STRING);
+       }
+
        MAP_VERIFY(map);
        *out = map;
 
@@ -2643,6 +2650,13 @@ int map_afrom_fields(TALLOC_CTX *ctx, map_t **out, map_t **parent_p, request_t *
                slen = tmpl_afrom_substr(map, &map->rhs, &FR_SBUFF_IN(rhs, strlen(rhs)),
                                         T_BARE_WORD, value_parse_rules_unquoted[T_BARE_WORD], &my_rules);
                if (slen <= 0) goto error;
+
+               /*
+                *      Xlat expansions are cast to strings for structural data types.
+                */
+               if (tmpl_attr_tail_da_is_structural(map->lhs) && (tmpl_is_xlat(map->rhs))) {
+                       tmpl_cast_set(map->rhs, FR_TYPE_STRING);
+               }
        }
 
        if (tmpl_needs_resolving(map->rhs)) {