]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
fix fr_dict_unknown_add(). Addresses #1883
authorAlan T. DeKok <aland@freeradius.org>
Fri, 20 Jan 2017 17:12:14 +0000 (12:12 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 20 Jan 2017 18:18:52 +0000 (13:18 -0500)
When an admin uses Attr-26 in the config files, this function
needs to add Attr-26, and then return the newly-defined Attr-26,
and NOT return Vendor-Specific

src/lib/dict.c

index 1be204bad60c33ee4e90b00594bd5862a5bdf3c5..689c4d8a7296b417687b09a83d18380e30f8fa98 100644 (file)
@@ -2766,6 +2766,9 @@ fr_dict_attr_t const *fr_dict_unknown_add(fr_dict_t *dict, fr_dict_attr_t const
 
        if (!old) return NULL;
 
+       da = fr_dict_attr_by_name(dict, old->name);
+       if (da) return da;
+
        /*
         *      Define the complete unknown hierarchy
         */
@@ -2775,9 +2778,6 @@ fr_dict_attr_t const *fr_dict_unknown_add(fr_dict_t *dict, fr_dict_attr_t const
                parent = old->parent;
        }
 
-       da = fr_dict_attr_child_by_num(parent, old->attr);
-       if (da) return da;
-
        memcpy(&flags, &old->flags, sizeof(flags));
        flags.is_unknown = false;
 
@@ -2787,10 +2787,13 @@ fr_dict_attr_t const *fr_dict_unknown_add(fr_dict_t *dict, fr_dict_attr_t const
         */
        if (old->type == PW_TYPE_VENDOR) if (fr_dict_vendor_add(dict, old->name, old->attr) < 0) return NULL;
 
-       if (fr_dict_attr_add(dict, old->parent, old->name, old->attr, old->type, flags) < 0) return NULL;
-
-       da = fr_dict_attr_child_by_num(parent, old->attr);
-       return da;
+       /*
+        *      Add the unknown by NAME.  e.g. if the admin does "Attr-26", we want
+        *      to return "Attr-26", and NOT "Vendor-Specific".  The rest of the server
+        *      is responsible for converting "Attr-26 = 0x..." to an actual attribute,
+        *      if it so desires.
+        */
+       return fr_dict_attr_add_by_name(dict, old->parent, old->name, old->attr, old->type, flags);
 }
 
 /** Free dynamically allocated (unknown attributes)