From: Alan T. DeKok Date: Thu, 7 Aug 2025 01:20:48 +0000 (-0400) Subject: set flags before allocating parent X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3cf9a831ae8980d4e02241ac275aefded1ad33be;p=thirdparty%2Ffreeradius-server.git set flags before allocating parent 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 --- diff --git a/src/lib/util/dict_ext_priv.h b/src/lib/util/dict_ext_priv.h index 254fb4c5cad..daf9d2b3eea 100644 --- a/src/lib/util/dict_ext_priv.h +++ b/src/lib/util/dict_ext_priv.h @@ -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 diff --git a/src/lib/util/dict_util.c b/src/lib/util/dict_util.c index c5538bbeedf..42e13e81893 100644 --- a/src/lib/util/dict_util.c +++ b/src/lib/util/dict_util.c @@ -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; }