]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
the LHS of this map is always an attribute
authorAlan T. DeKok <aland@freeradius.org>
Wed, 26 Mar 2025 21:01:21 +0000 (17:01 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 26 Mar 2025 21:04:12 +0000 (17:04 -0400)
which is enforced, but then later code also checks if the LHS is
an attribute.  So remove the duplicate checks

src/lib/server/map.c

index e8d6dedc7b4de40bbcf39fbcba22104a1d53f08e..c56c1e022394ffa65c2a81b063f0ef068c2444dd 100644 (file)
@@ -474,6 +474,7 @@ ssize_t map_afrom_substr(TALLOC_CTX *ctx, map_t **out, map_t **parent_p, fr_sbuf
        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;
+       fr_dict_attr_t const            *enumv;
        tmpl_rules_t                    our_rhs_rules;
 
        if (parent_p) {
@@ -561,6 +562,7 @@ ssize_t map_afrom_substr(TALLOC_CTX *ctx, map_t **out, map_t **parent_p, fr_sbuf
                talloc_free(map);
                FR_SBUFF_ERROR_RETURN(&our_in);
        }
+       fr_assert(tmpl_is_attr(map->lhs));
 
        (void)fr_sbuff_adv_past_whitespace(&our_in, SIZE_MAX, tt);
        fr_sbuff_marker(&m_op, &our_in);
@@ -607,7 +609,7 @@ ssize_t map_afrom_substr(TALLOC_CTX *ctx, map_t **out, map_t **parent_p, fr_sbuf
         *      only be an attribute, etc.  Not trivial, so we'll just
         *      skip all that for now.
         */
-       if (tmpl_is_attr(map->lhs)) switch (tmpl_attr_tail_da(map->lhs)->type) {
+       switch (tmpl_attr_tail_da(map->lhs)->type) {
                case FR_TYPE_STRUCTURAL:
                        if ((map->op == T_OP_REG_EQ) || (map->op == T_OP_REG_NE)) {
                                fr_sbuff_set(&our_in, &m_op);
@@ -682,21 +684,16 @@ parse_rhs:
                goto check_for_child;
        }
 
+       enumv = tmpl_attr_tail_da(map->lhs);
+
        /*
-        *      If the LHS is an attribute, we can parse enum names from the RHS.
+        *      LHS is a structural type.  The RHS is either empty (create empty LHS), or it's a string
+        *      containing a list of attributes to create.
         */
-       if (tmpl_is_attr(map->lhs)) {
-               fr_dict_attr_t const *enumv = tmpl_attr_tail_da(map->lhs);
-
-               /*
-                *      LHS is a structural type.  The RHS is either empty (create empty LHS), or it's a string
-                *      containing a list of attributes to create.
-                */
-               if (fr_type_is_leaf(enumv->type)) {
-                       our_rhs_rules = *rhs_rules;
-                       our_rhs_rules.enumv = enumv;
-                       rhs_rules = &our_rhs_rules;
-               }
+       if (fr_type_is_leaf(enumv->type)) {
+               our_rhs_rules = *rhs_rules;
+               our_rhs_rules.enumv = enumv;
+               rhs_rules = &our_rhs_rules;
        }
 
        fr_sbuff_out_by_longest_prefix(&slen, &token, cond_quote_table, &our_in, T_BARE_WORD);