From: Alan T. DeKok Date: Wed, 6 Oct 2021 19:54:05 +0000 (-0400) Subject: minor cleanups X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=73276c6ffddad317650e8c99ebcaa7411ecf4199;p=thirdparty%2Ffreeradius-server.git minor cleanups --- diff --git a/src/lib/util/struct.c b/src/lib/util/struct.c index 62ba9b56d9..50e4428c14 100644 --- a/src/lib/util/struct.c +++ b/src/lib/util/struct.c @@ -108,14 +108,18 @@ ssize_t fr_struct_from_network(TALLOC_CTX *ctx, fr_dcursor_t *cursor, size_t struct_len; struct_len = (p[0] << 8) | p[1]; - if ((struct_len + 2) > data_len) { - FR_PROTO_TRACE("too much data?"); + if ((p + struct_len + 2) > end) { + FR_PROTO_TRACE("Length header is larger than remaining data"); goto unknown; } - data_len = struct_len + 2; - end = data + data_len; + /* + * Skip the "length" field, and tell the decoder + * to stop at the end of the length field. + */ p += 2; + end = p + struct_len; + data_len = struct_len + 2; } while (p < end) {