]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
initialize length and use correct checks
authorAlan T. DeKok <aland@freeradius.org>
Thu, 16 Jul 2026 23:35:27 +0000 (19:35 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 17 Jul 2026 12:36:55 +0000 (08:36 -0400)
src/protocols/radius/list.c

index 93ee42b289a955b05b39bcc503615790795b2d9e..35e0ce249a7eb634a4862bfbac3fd3e2862ef006 100644 (file)
@@ -706,11 +706,15 @@ int fr_packet_list_recv(fr_packet_list_t *pl, fd_set *set, TALLOC_CTX *ctx, fr_p
                        int rcode;
                        ps = &pl->sockets[start];
 
+                       ps->used = 0;
                        rcode = fr_tcp_read_packet(ps->socket.fd, ps->buffer, ps->bufsize,
                                                   &ps->used, max_attributes, require_message_authenticator);
                        if (rcode <= 0) return rcode;
 
-                       fr_assert(ps->used >= RADIUS_HEADER_LENGTH);
+                       if (ps->used < RADIUS_HEADER_LENGTH) {
+                               fr_strerror_printf("TCP packet too short: %zu", ps->used);
+                               return -1;
+                       }
 
                        packet = fr_packet_alloc(ctx, false);
                        if (!packet) return -1;