]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
allow variable-length fields as the last one in a struct
authorAlan T. DeKok <aland@freeradius.org>
Wed, 10 Oct 2018 19:36:07 +0000 (15:36 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 10 Oct 2018 19:36:07 +0000 (15:36 -0400)
src/lib/util/dict.c

index c9c4b90fee43018246f43d8a9c75395c9012f53f..dc50475fc5c3a988ba619bfe037173b7ff6e8c05 100644 (file)
@@ -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;
+                       }
                }
 
                /*