]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Use parse rules when parsing call_env data
authorNick Porter <nick@portercomputing.co.uk>
Fri, 11 Oct 2024 09:25:58 +0000 (10:25 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Fri, 11 Oct 2024 09:36:16 +0000 (10:36 +0100)
Otherwise we don't properly unescape fixed values (e.g. \" in a double quoted string remains \" rather than becoming ")

src/lib/unlang/call_env.c
src/modules/rlm_detail/rlm_detail.c
src/modules/rlm_files/rlm_files.c
src/modules/rlm_linelog/rlm_linelog.c
src/modules/rlm_smtp/rlm_smtp.c
src/modules/rlm_sql/rlm_sql.c
src/modules/rlm_sqlippool/rlm_sqlippool.c

index 71df113c535c5731fb3b00849e55bc712498cd13..2805d6b685361e1715de88d8533d0a5beaa503c1 100644 (file)
@@ -380,7 +380,8 @@ int call_env_parse_pair(TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rules,
 
        if (tmpl_afrom_substr(ctx, &parsed_tmpl,
                              &FR_SBUFF_IN(cf_pair_value(to_parse), talloc_strlen(cf_pair_value(to_parse))),
-                             cf_pair_value_quote(to_parse), NULL, t_rules) < 0) {
+                             cf_pair_value_quote(to_parse), value_parse_rules_quoted[cf_pair_value_quote(to_parse)],
+                             t_rules) < 0) {
                return -1;
        }
        *(void **)out = parsed_tmpl;
index dceb8bc9a748dd9e5b4576ffe5937568c0f81e14..8966e1588f51c76c285c6cefa316191736252bde 100644 (file)
@@ -420,7 +420,8 @@ static int call_env_filename_parse(TALLOC_CTX *ctx, void *out, tmpl_rules_t cons
 
        if (tmpl_afrom_substr(ctx, &parsed,
                              &FR_SBUFF_IN(cf_pair_value(to_parse), talloc_array_length(cf_pair_value(to_parse)) - 1),
-                             cf_pair_value_quote(to_parse), NULL, &our_rules) < 0) return -1;
+                             cf_pair_value_quote(to_parse), value_parse_rules_quoted[cf_pair_value_quote(to_parse)],
+                             &our_rules) < 0) return -1;
 
        *(void **)out = parsed;
        return 0;
index ac7b04fdcbcdbe026f829fd797c2b6f0f35504f0..f8e96ec7f41a8c40c96119b5d61e6b1c9a7f186d 100644 (file)
@@ -662,7 +662,8 @@ static int call_env_parse(TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rule
 
        if (tmpl_afrom_substr(ctx, &files_data->key_tmpl,
                              &FR_SBUFF_IN(cf_pair_value(to_parse), talloc_array_length(cf_pair_value(to_parse)) - 1),
-                             cf_pair_value_quote(to_parse), NULL, t_rules) < 0) return -1;
+                             cf_pair_value_quote(to_parse), value_parse_rules_quoted[cf_pair_value_quote(to_parse)],
+                             t_rules) < 0) return -1;
 
        keytype = tmpl_expanded_type(files_data->key_tmpl);
        if (fr_htrie_hint(keytype) == FR_HTRIE_INVALID) {
index 8afc73b70388dd6a0bde0e211b6ba2a5057414d1..d57de4da7aeaa95602e6b6754fdb696dbb181873 100644 (file)
@@ -903,7 +903,8 @@ static int call_env_filename_parse(TALLOC_CTX *ctx, void *out, tmpl_rules_t cons
 
        if (tmpl_afrom_substr(ctx, &parsed,
                              &FR_SBUFF_IN(cf_pair_value(to_parse), talloc_array_length(cf_pair_value(to_parse)) - 1),
-                             cf_pair_value_quote(to_parse), NULL, &our_rules) < 0) return -1;
+                             cf_pair_value_quote(to_parse), value_parse_rules_quoted[cf_pair_value_quote(to_parse)],
+                             &our_rules) < 0) return -1;
 
        *(void **)out = parsed;
        return 0;
index cd165f6e2dc4fb089e4a94710351a6e5a40059ea..c29d039f246b55c2f29abd5e6220f2b7f02c3d6f 100644 (file)
@@ -971,7 +971,8 @@ static int smtp_header_section_parse(TALLOC_CTX *ctx, call_env_parsed_head_t *ou
 
                slen = tmpl_afrom_substr(parsed_env, &parsed_tmpl,
                                         &FR_SBUFF_IN(to_parse, talloc_array_length(to_parse) - 1),
-                                        cf_pair_value_quote(cp), NULL, t_rules);
+                                        cf_pair_value_quote(cp), value_parse_rules_quoted[cf_pair_value_quote(cp)],
+                                        t_rules);
                talloc_free(to_parse);
 
                if (slen <= 0) {
index 61f677744d12464b4940045d6c42f07ea6e30cfc..0b5e2b0dea0126a53293f1d793c7cc911c7e4198 100644 (file)
@@ -1950,7 +1950,8 @@ static int logfile_call_env_parse(TALLOC_CTX *ctx, call_env_parsed_head_t *out,
 
        if (tmpl_afrom_substr(parsed_env, &parsed_tmpl,
                              &FR_SBUFF_IN(cf_pair_value(to_parse), talloc_array_length(cf_pair_value(to_parse)) - 1),
-                             cf_pair_value_quote(to_parse), NULL, &our_rules) < 0) {
+                             cf_pair_value_quote(to_parse), value_parse_rules_quoted[cf_pair_value_quote(to_parse)],
+                             &our_rules) < 0) {
        error:
                call_env_parsed_free(out, parsed_env);
                return -1;
@@ -2021,7 +2022,8 @@ static int query_call_env_parse(TALLOC_CTX *ctx, call_env_parsed_head_t *out, tm
 
                slen = tmpl_afrom_substr(parsed_env, &parsed_tmpl,
                                         &FR_SBUFF_IN(cf_pair_value(to_parse), talloc_array_length(cf_pair_value(to_parse)) - 1),
-                                        cf_pair_value_quote(to_parse), NULL, &our_rules);
+                                        cf_pair_value_quote(to_parse), value_parse_rules_quoted[cf_pair_value_quote(to_parse)],
+                                        &our_rules);
                if (slen <= 0) {
                        cf_canonicalize_error(to_parse, slen, "Failed parsing query", cf_pair_value(to_parse));
                error:
@@ -2373,7 +2375,8 @@ static int call_env_parse(TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rule
 
        if (tmpl_afrom_substr(ctx, &parsed_tmpl,
                              &FR_SBUFF_IN(cf_pair_value(to_parse), talloc_array_length(cf_pair_value(to_parse)) - 1),
-                             cf_pair_value_quote(to_parse), NULL, &our_rules) < 0) return -1;
+                             cf_pair_value_quote(to_parse), value_parse_rules_quoted[cf_pair_value_quote(to_parse)],
+                             &our_rules) < 0) return -1;
        *(void **)out = parsed_tmpl;
        return 0;
 }
index 23a7c6b42bb39a4d9aacd488c95f81b8ed7740a2..81a384600ec244ba5dbab157d8c8497c5ea82592 100644 (file)
@@ -717,7 +717,8 @@ static int call_env_parse(TALLOC_CTX *ctx, void *out, tmpl_rules_t const *t_rule
 
        if (tmpl_afrom_substr(ctx, &parsed_tmpl,
                              &FR_SBUFF_IN(cf_pair_value(to_parse), talloc_array_length(cf_pair_value(to_parse)) - 1),
-                             cf_pair_value_quote(to_parse), NULL, &our_rules) < 0) return -1;
+                             cf_pair_value_quote(to_parse), value_parse_rules_quoted[cf_pair_value_quote(to_parse)],
+                             &our_rules) < 0) return -1;
        *(void **)out = parsed_tmpl;
        return 0;
 }