]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
structs which are variable length have "flags.length == 0"
authorAlan T. DeKok <aland@freeradius.org>
Thu, 11 Oct 2018 17:22:20 +0000 (13:22 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 11 Oct 2018 17:22:44 +0000 (13:22 -0400)
src/lib/util/dict.c

index cb8fa737fbae2ba36850ea4ae1a064f6e555202f..4faa2b743e5d8c070ee6f3784474944c89bc77ed 100644 (file)
@@ -1107,16 +1107,27 @@ static bool dict_attr_fields_valid(fr_dict_t *dict, fr_dict_attr_t const *parent
                 *      Sneak in the length of the children.
                 */
                memcpy(&mutable, &parent, sizeof(mutable));
-               mutable->flags.length += flags->length;
 
                /*
                 *      The struct has a maximum size.  Complain if we exceed it.
                 */
-               if (mutable->flags.type_size && (mutable->flags.length > mutable->flags.type_size)) {
-                       fr_strerror_printf("Child attribute causes struct to overflow maximum size of %d octets",
-                                          mutable->flags.type_size);
-                       goto error;
+               if (flags->length) {
+                       if (mutable->flags.type_size && ((mutable->flags.length + flags->length) > mutable->flags.type_size)) {
+                               fr_strerror_printf("Child attribute causes struct to overflow maximum size of %d octets",
+                                                  mutable->flags.type_size);
+                               goto error;
+                       }
+                       mutable->flags.length += flags->length;
+
+               } else {
+                       /*
+                        *      This is a bad hack... set the struct
+                        *      size to it's maximum value, which
+                        *      indicates that it has variable length.
+                        */
+                       mutable->flags.length = 0;
                }
+
        }
 
        return true;