]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
more checks for struct members
authorAlan T. DeKok <aland@freeradius.org>
Thu, 17 Mar 2022 12:12:43 +0000 (08:12 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 17 Mar 2022 14:46:53 +0000 (10:46 -0400)
known sized are OK, even if the underlying data type is variable
sized.

arrays have to be at the end of a struct.

src/lib/util/dict_validate.c

index 6496cadfae3f17dce92049dd8f20ccb850e39ff2..45ee20eaf7540c0d90a51e908f54e1df96de2583 100644 (file)
@@ -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;
                        }