From: Alan T. DeKok Date: Sat, 6 Dec 2025 16:24:30 +0000 (-0500) Subject: set the default type size for a dictionary X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dbab449fab3dccc788e2ba5d3f0d8e391e4adcef;p=thirdparty%2Ffreeradius-server.git set the default type size for a dictionary from the protocol library which we loaded. --- diff --git a/src/lib/util/dict_tokenize.c b/src/lib/util/dict_tokenize.c index 7d81e8b0502..66dd49b1e6e 100644 --- a/src/lib/util/dict_tokenize.c +++ b/src/lib/util/dict_tokenize.c @@ -317,8 +317,8 @@ static int dict_root_set(fr_dict_t *dict, char const *name, unsigned int proto_n fr_dict_attr_flags_t flags = { .is_root = 1, - .type_size = 1, - .length = 1 + .type_size = dict->proto->default_type_size, + .length = dict->proto->default_type_length, }; if (!fr_cond_assert(!dict->root)) { @@ -2836,7 +2836,6 @@ static int dict_read_process_protocol(dict_tokenize_ctx_t *dctx, char **argv, in unsigned int value; unsigned int type_size = 0; fr_dict_t *dict; - fr_dict_attr_t *mutable; unsigned int required_value; char const *required_name; bool require_dl = false; @@ -2995,12 +2994,11 @@ post_option: if (dict_protocol_add(dict) < 0) goto error; - mutable = UNCONST(fr_dict_attr_t *, dict->root); dict->string_based = string_based; - if (!type_size) { - mutable->flags.type_size = dict->proto->default_type_size; - mutable->flags.length = dict->proto->default_type_length; - } else { + if (type_size) { + fr_dict_attr_t *mutable; + + mutable = UNCONST(fr_dict_attr_t *, dict->root); mutable->flags.type_size = type_size; mutable->flags.length = 1; /* who knows... */ } diff --git a/src/lib/util/dict_util.c b/src/lib/util/dict_util.c index 791274a7b10..8778e758aee 100644 --- a/src/lib/util/dict_util.c +++ b/src/lib/util/dict_util.c @@ -4281,8 +4281,8 @@ fr_dict_t *fr_dict_protocol_alloc(fr_dict_t const *parent) .is_root = true, .local = true, .internal = true, - .type_size = 2, - .length = 2 + .type_size = parent->root->flags.type_size, + .length = parent->root->flags.length, }; dict = dict_alloc(UNCONST(fr_dict_t *, parent));