]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
set flags before allocating parent developer/alandekok master
authorAlan T. DeKok <aland@freeradius.org>
Thu, 7 Aug 2025 01:20:48 +0000 (21:20 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 7 Aug 2025 01:20:48 +0000 (21:20 -0400)
and unknown attributes can allocate EXT_VENDOR

which helps with unknown VSAs.  They previously result in a
Vendor-Specific { Foo { } } being allocated, and then an error
returned of "dict is read only".

At that point, the decoder would then create a raw top-level
attribute

src/lib/util/dict_ext_priv.h
src/lib/util/dict_util.c

index 254fb4c5cadacd24d1be9cb97a86c7ae9628f39e..daf9d2b3eeacd64970c967c0d8d2414d3eb76636 100644 (file)
@@ -88,7 +88,7 @@ static inline void *dict_attr_ext_copy(fr_dict_attr_t **da_out_p, fr_dict_attr_t
         */
 #ifndef NDEBUG
        if ((*da_out_p)->flags.is_unknown && ((*da_out_p)->type == FR_TYPE_OCTETS)) {
-               fr_assert(ext == FR_DICT_ATTR_EXT_PROTOCOL_SPECIFIC);
+               fr_assert((ext == FR_DICT_ATTR_EXT_PROTOCOL_SPECIFIC) || (ext == FR_DICT_ATTR_EXT_VENDOR));
        }
 #endif
 
index c5538bbeedf0d0fdb90da994e71bb6e75bd800b7..42e13e81893c321ec45f91d009aedcbdaa4d91ed 100644 (file)
@@ -683,7 +683,6 @@ int dict_attr_parent_init(fr_dict_attr_t **da_p, fr_dict_attr_t const *parent)
 {
        fr_dict_attr_t *da = *da_p;
 
-
        if (unlikely((*da_p)->type == FR_TYPE_NULL)) {
                fr_strerror_const("Attribute type must be set before initialising parent.  Use dict_attr_type_init() first");
                return -1;
@@ -855,12 +854,12 @@ int dict_attr_init_common(char const *filename, int line,
 
        if (unlikely(dict_attr_type_init(da_p, type) < 0)) return -1;
 
+       if (args->flags) (*da_p)->flags = *args->flags;
+
        if (parent && (dict_attr_parent_init(da_p, parent) < 0)) return -1;
 
        if (args->ref && (dict_attr_ref_aset(da_p, args->ref, FR_DICT_ATTR_REF_ALIAS) < 0)) return -1;
 
-       if (args->flags) (*da_p)->flags = *args->flags;
-
        return 0;
 }