From: Alan T. DeKok Date: Thu, 19 Oct 2023 21:12:23 +0000 (-0400) Subject: try to parse things inside of a {...} block X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a9970927eef06a6a05e5087bf95047b31c68fa8;p=thirdparty%2Ffreeradius-server.git try to parse things inside of a {...} block if this doesn't work, it should be reverted --- diff --git a/src/lib/server/map.c b/src/lib/server/map.c index 09d05be3aa9..86f6d66cceb 100644 --- a/src/lib/server/map.c +++ b/src/lib/server/map.c @@ -412,7 +412,9 @@ ssize_t map_afrom_substr(TALLOC_CTX *ctx, map_t **out, map_t **parent_p, fr_sbuf fr_sbuff_t our_in = FR_SBUFF(in); fr_sbuff_marker_t m_lhs, m_rhs, m_op; fr_sbuff_term_t const *tt = p_rules ? p_rules->terminals : NULL; - map_t *parent, *new_parent; + map_t *parent, *new_parent, *child; + tmpl_rules_t our_lhs_rules; + if (parent_p) { new_parent = parent = *parent_p; @@ -440,8 +442,6 @@ ssize_t map_afrom_substr(TALLOC_CTX *ctx, map_t **out, map_t **parent_p, fr_sbuf default: { - tmpl_rules_t our_lhs_rules; - if (lhs_rules) { our_lhs_rules = *lhs_rules; } else { @@ -594,6 +594,26 @@ ssize_t map_afrom_substr(TALLOC_CTX *ctx, map_t **out, map_t **parent_p, fr_sbuf fr_sbuff_adv_past_whitespace(&our_in, SIZE_MAX, tt); + if (lhs_rules) { + our_lhs_rules = *lhs_rules; + } else { + memset(&our_lhs_rules, 0, sizeof(our_lhs_rules)); + } + our_lhs_rules.attr.namespace = tmpl_attr_tail_da(map->lhs); + + if (map_afrom_attr_str(map, &child, fr_sbuff_current(&our_in), &our_lhs_rules, rhs_rules) < 0) { + fr_sbuff_set(&our_in, &m_rhs); + fr_strerror_const("Failed parsing map contents"); + goto error; + } + map_list_insert_tail(&map->child, child); + + /* + * @todo - check for commas and repeat? + */ + + fr_sbuff_adv_past_whitespace(&our_in, SIZE_MAX, tt); + /* * Peek at the next character. If it's * '}', stop. Otherwise, call ourselves