From 3cf9a831ae8980d4e02241ac275aefded1ad33be Mon Sep 17 00:00:00 2001 From: "Alan T. DeKok" Date: Wed, 6 Aug 2025 21:20:48 -0400 Subject: [PATCH] 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 --- src/lib/util/dict_ext_priv.h | 2 +- src/lib/util/dict_util.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lib/util/dict_ext_priv.h b/src/lib/util/dict_ext_priv.h index 254fb4c5ca..daf9d2b3ee 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 c5538bbeed..42e13e8189 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; } -- 2.47.2