Skip to content

Commit

Permalink
Use parse rules when parsing call_env data
Browse files Browse the repository at this point in the history
Otherwise we don't properly unescape fixed values (e.g. \" in a double quoted string remains \" rather than becoming ")
  • Loading branch information
ndptech committed Oct 11, 2024
1 parent aac0742 commit 52a11db
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/lib/unlang/call_env.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/modules/rlm_detail/rlm_detail.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/modules/rlm_files/rlm_files.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion src/modules/rlm_linelog/rlm_linelog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/modules/rlm_smtp/rlm_smtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 6 additions & 3 deletions src/modules/rlm_sql/rlm_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion src/modules/rlm_sqlippool/rlm_sqlippool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 52a11db

Please sign in to comment.