]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
allow EVS for unknown attributes, too
authorAlan T. DeKok <aland@freeradius.org>
Tue, 24 Jan 2017 21:59:36 +0000 (16:59 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 24 Jan 2017 22:05:59 +0000 (17:05 -0500)
src/lib/dict.c

index 3019716880076fd5cced5ecf14e05e8f88adb530..133585c16d29b13476a7e668218fa0172a7f10f2 100644 (file)
@@ -3193,9 +3193,10 @@ int fr_dict_unknown_from_oid(fr_dict_t *dict, fr_dict_attr_t *vendor_da, fr_dict
        p = q;
 
        /*
-        *      The common case: Attr-26.  Just create it and go.
+        *      The common case: Attr-X,  Just create it and go.
         */
        if (!*p) {
+do_create:
                if (!da) {
                        fr_strerror_printf("Failed creating attribute");
                        return -1;
@@ -3224,6 +3225,7 @@ int fr_dict_unknown_from_oid(fr_dict_t *dict, fr_dict_attr_t *vendor_da, fr_dict
         */
        child = fr_dict_attr_child_by_num(parent, attr);
        if (!child) {
+fail:
                fr_strerror_printf("Cannot parse names without dictionaries");
                return -1;
        }
@@ -3237,10 +3239,44 @@ int fr_dict_unknown_from_oid(fr_dict_t *dict, fr_dict_attr_t *vendor_da, fr_dict
                return -1;
        }
 
+       /*
+        *      Attr-241.X
+        *
+        *      X may be 26, in which case we allow unknown vendors under it.
+        */
+       if ((child->type == PW_TYPE_EXTENDED) || (child->type == PW_TYPE_LONG_EXTENDED)) {
+               parent = child;
+
+               num = strtoul(p + 5, &q, 10);
+               if (!num || (num >= UINT_MAX)) {
+                       fr_strerror_printf("Invalid value in attribute name '%s'", name);
+                       return -1;
+               }
+
+               attr = num;
+               p = q;
+
+               /*
+                *      The common case: Attr-241.X,  Just create it and go.
+                */
+               if (!*p) goto do_create;
+
+               /*
+                *      Attr-241.X.  Does X exist?
+                */
+               child = fr_dict_attr_child_by_num(parent, attr);
+               if (!child) goto fail;
+
+               /*
+                *      Fall through to checking for EVS.
+                */
+       }
+
        /*
         *      Attr-26 means that the following data is a 32-bit vendor ID.
         */
-       if (child->type == PW_TYPE_VSA) {
+       if ((child->type == PW_TYPE_VSA) ||
+           (child->type == PW_TYPE_EVS)) {
                fr_dict_attr_t const *dv;
 
                num = strtoul(p + 1, &q, 10);