]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
fix "can contain" for structs && key fields
authorAlan T. DeKok <aland@freeradius.org>
Sat, 11 Feb 2023 14:01:12 +0000 (09:01 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 11 Feb 2023 14:01:12 +0000 (09:01 -0500)
src/lib/util/dict_util.c

index 9bf38a836f307d5e1b9fdc0342dc877bbb883d59..0f26edc58a3381eed759706245e1e6cbc35d70f0 100644 (file)
@@ -4326,8 +4326,6 @@ bool fr_dict_attr_can_contain(fr_dict_attr_t const *parent, fr_dict_attr_t const
 
        /*
         *      Only structural types can have children.
-        *
-        *      @todo - yes, "key" members of FR_TYPE_STRUCT.
         */
        if (!fr_type_structural[parent->type]) return false;
 
@@ -4356,6 +4354,12 @@ bool fr_dict_attr_can_contain(fr_dict_attr_t const *parent, fr_dict_attr_t const
                return (ref && (ref->dict == child->dict));
        }
 
+       /*
+        *      Key fields can have children, but everyone else thinks
+        *      that the struct is the parent.  <sigh>
+        */
+       if ((parent->type == FR_TYPE_STRUCT) && child->parent->parent == parent) return true;
+
        /*
         *      We're in the same protocol dictionary, but the child
         *      isn't directly from the parent.  Therefore the only