]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
check for "too small" earlier
authorAlan T. DeKok <aland@freeradius.org>
Thu, 23 Mar 2023 13:43:48 +0000 (09:43 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 23 Mar 2023 13:43:48 +0000 (09:43 -0400)
so that we don't allocate VPs, try to decode them, and then discover
that it never would have worked.

src/lib/util/struct.c

index f09f3ea215b1d4f8fc338a08a8f6029fc8d94e10..1687b704f9793c87e3a25047c770bd3b33069c3d 100644 (file)
@@ -242,7 +242,12 @@ ssize_t fr_struct_from_network(TALLOC_CTX *ctx, fr_pair_list_t *out,
                 *      The child is variable sized, OR it's an array.
                 *      Eat up the rest of the data.
                 */
-               if (!child_length || (child->flags.array)) child_length = (end - p);
+               if (!child_length || (child->flags.array)) {
+                       child_length = (end - p);
+
+               } else if ((size_t) (end - p) < child_length) {
+                       goto unknown;
+               }
 
                /*
                 *      Magic values get the callback called.