]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
map_afrom_cp: unescape double-quoted and back-quoted RHS prior to parsing it (#4590)
authorMax Khon <fjoe@samodelkin.net>
Tue, 5 Jul 2022 13:34:28 +0000 (16:34 +0300)
committerGitHub <noreply@github.com>
Tue, 5 Jul 2022 13:34:28 +0000 (09:34 -0400)
src/lib/server/map.c

index a7d5acd6de0107d0b55c693643b468db6b63999b..972f095af0e1af4c436e32b3d416dc9bf28024c0 100644 (file)
@@ -99,6 +99,7 @@ int map_afrom_cp(TALLOC_CTX *ctx, map_t **out, map_t *parent, CONF_PAIR *cp,
 {
        map_t           *map;
        char const      *attr, *value, *marker_subject;
+       fr_sbuff_parse_rules_t const *p_rules;
        ssize_t         slen;
        fr_token_t      type;
 
@@ -164,11 +165,23 @@ int map_afrom_cp(TALLOC_CTX *ctx, map_t **out, map_t *parent, CONF_PAIR *cp,
         *      RHS might be an attribute reference.
         */
        type = cf_pair_value_quote(cp);
+       p_rules = value_parse_rules_unquoted[type]; /* We're not searching for quotes */
+       if (type == T_DOUBLE_QUOTED_STRING || type == T_BACK_QUOTED_STRING) {
+               char *unescaped_value;
+               slen = fr_sbuff_out_aunescape_until(map, &unescaped_value,
+                               &FR_SBUFF_IN(value, strlen(value)), SIZE_MAX, p_rules->terminals, p_rules->escapes);
+               if (slen < 0) {
+                       marker_subject = value;
+                       goto marker;
+               }
+               value = unescaped_value;
+               p_rules = NULL;
+       }
 
        slen = tmpl_afrom_substr(map, &map->rhs,
                                 &FR_SBUFF_IN(value, strlen(value)),
                                 type,
-                                value_parse_rules_unquoted[type],      /* We're not searching for quotes */
+                                p_rules,
                                 rhs_rules);
        if (slen < 0) {
                marker_subject = value;