From: Alan T. DeKok Date: Wed, 10 Oct 2018 19:36:07 +0000 (-0400) Subject: allow variable-length fields as the last one in a struct X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f77d466ffa2f9faefd61a21d860119dff3210033;p=thirdparty%2Ffreeradius-server.git allow variable-length fields as the last one in a struct --- diff --git a/src/lib/util/dict.c b/src/lib/util/dict.c index c9c4b90fee4..dc50475fc5c 100644 --- a/src/lib/util/dict.c +++ b/src/lib/util/dict.c @@ -1064,14 +1064,22 @@ static bool dict_attr_fields_valid(fr_dict_t *dict, fr_dict_attr_t const *parent fr_strerror_printf("Children of 'struct' type attributes MUST be numbered consecutively."); goto error; } - } - /* - * STRUCTs will have their length filled in later. - */ - if ((type != FR_TYPE_STRUCT) && (flags->length == 0)) { - fr_strerror_printf("Children of 'struct' type attributes MUST have fixed length."); - goto error; + if (dict_attr_sizes[sibling->type][1] == ~(size_t) 0) { + fr_strerror_printf("Only the last child of a 'struct' attribute can have variable length"); + goto error; + } + + } else { + /* + * The first child can't be variable length, that's stupid. + * + * STRUCTs will have their length filled in later. + */ + if ((type != FR_TYPE_STRUCT) && (flags->length == 0)) { + fr_strerror_printf("Children of 'struct' type attributes MUST have fixed length."); + goto error; + } } /*