From: Alan T. DeKok Date: Thu, 17 Mar 2022 12:12:43 +0000 (-0400) Subject: more checks for struct members X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=76023c773bea8945127cb383f1e004ce977dff59;p=thirdparty%2Ffreeradius-server.git more checks for struct members known sized are OK, even if the underlying data type is variable sized. arrays have to be at the end of a struct. --- diff --git a/src/lib/util/dict_validate.c b/src/lib/util/dict_validate.c index 6496cadfae3..45ee20eaf75 100644 --- a/src/lib/util/dict_validate.c +++ b/src/lib/util/dict_validate.c @@ -519,15 +519,18 @@ bool dict_attr_flags_valid(fr_dict_t *dict, fr_dict_attr_t const *parent, } /* - * @todo - allow dns_label encoding as - * the first member. + * Variable sized elements cannot have anything after them in a struct. */ - if (sibling->flags.length == 0) switch (sibling->type) { - case FR_TYPE_LEAF: - break; + if (!sibling->flags.length && !sibling->flags.is_known_width) { + fr_strerror_const("No other field can follow a struct MEMBER which is variable sized"); + return false; + } - default: - fr_strerror_const("Only the last child of a 'struct' attribute can have variable length"); + /* + * The same goes for arrays. + */ + if (sibling->flags.array) { + fr_strerror_const("No other field can follow a struct MEMBER which is 'array'"); return false; }