From: Alan T. DeKok Date: Sun, 19 Sep 2021 13:40:04 +0000 (-0400) Subject: ENUMs have values, but no children X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e06367583616d04de803cc5cc282a5f3548fe16;p=thirdparty%2Ffreeradius-server.git ENUMs have values, but no children and add tests --- diff --git a/src/lib/util/dict_fixup.c b/src/lib/util/dict_fixup.c index e7e1000121..ac4865c432 100644 --- a/src/lib/util/dict_fixup.c +++ b/src/lib/util/dict_fixup.c @@ -493,15 +493,17 @@ static inline CC_HINT(always_inline) int dict_fixup_clone_apply(UNUSED dict_fixu /* * Copy children of the DA we're cloning. */ - if (dict_attr_acopy_children(dict, cloned, da) < 0) { - fr_strerror_printf("Failed cloning attribute '%s' from children of %s", da->name, fixup->ref); - return -1; - } + if (dict_attr_children(da)) { + if (dict_attr_acopy_children(dict, cloned, da) < 0) { + fr_strerror_printf("Failed cloning attribute '%s' from children of %s", da->name, fixup->ref); + return -1; + } - if (dict_attr_child_add(fr_dict_attr_unconst(fixup->parent), cloned) < 0) { - fr_strerror_printf("Failed adding cloned attribute %s", da->name); - talloc_free(cloned); - return -1; + if (dict_attr_child_add(fr_dict_attr_unconst(fixup->parent), cloned) < 0) { + fr_strerror_printf("Failed adding cloned attribute %s", da->name); + talloc_free(cloned); + return -1; + } } if (dict_attr_add_to_namespace(fixup->parent, cloned) < 0) return -1; diff --git a/src/tests/dict/base.dict b/src/tests/dict/base.dict index cdf7796dbe..7b4e4fcd7c 100644 --- a/src/tests/dict/base.dict +++ b/src/tests/dict/base.dict @@ -26,9 +26,18 @@ ATTRIBUTE Base-TLV 15 tlv # Ignore extended and evs -ATTRIBUTE Base-Integer64 19 integer64 +# +# Define an ENUM +# +ENUM base-enum-uint64 uint64 +VALUE base-enum-uint64 one 1 +VALUE base-enum-uint64 two 2 +VALUE base-enum-uint64 three 3 + +ATTRIBUTE Base-Integer64 19 uint64 enum=base-enum-uint64 ATTRIBUTE Base-IPv4-Prefix 20 ipv4prefix # Ignore VSA, VENDOR, timeval, boolean, combo-ip-prefix, decimal... for now + END-PROTOCOL TEST