]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
canonicalize tmpl attributes.
authorAlan T. DeKok <aland@freeradius.org>
Fri, 30 Jun 2023 13:39:08 +0000 (09:39 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 30 Jun 2023 13:39:08 +0000 (09:39 -0400)
We can have multiple attributes with the same name.  In which case
when the duplicate name is used, that reference should be replaced
by a reference to the canonical name.

src/main/tmpl.c

index 6ec25987ba8470e555cb7dea7456c2c9e71eae10..eed4a8695085ede54af94bfe73f5f626cf999c5d 100644 (file)
@@ -579,6 +579,7 @@ ssize_t tmpl_from_attr_substr(vp_tmpl_t *vpt, char const *name,
        long num;
        char *q;
        tmpl_type_t type = TMPL_TYPE_ATTR;
+       DICT_ATTR const *da;
 
        value_pair_tmpl_attr_t attr;    /* So we don't fill the tmpl with junk and then error out */
 
@@ -693,6 +694,16 @@ ssize_t tmpl_from_attr_substr(vp_tmpl_t *vpt, char const *name,
                goto do_num;
        }
 
+       /*
+        *      Canonicalize the attribute.
+        *
+        *      We can define multiple names for one attribute.  In
+        *      which case we only use the canonical name.
+        */
+       da = dict_attrbyvalue(attr.da->attr, attr.da->vendor);
+       if (attr.da != da) attr.da = da;
+
+
        /*
         *      The string MIGHT have a tag.
         */