]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
if we're not using the packet contents, don't call rad_recv()
authorAlan T. DeKok <aland@freeradius.org>
Mon, 19 May 2025 19:26:58 +0000 (14:26 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 19 May 2025 19:28:48 +0000 (14:28 -0500)
which avoids all of the issues with reading partial packets from
a TCP socket.  And then also means that we avoid issues with
reading the TCP listen() socket versus the TCP accept() socket.

src/main/listen.c

index 3cbd4f88f93d6b6155ef1faae7d74191fc26c7fc..68da367dc1c164e509f6421b8f47b79b097cf5d0 100644 (file)
@@ -279,13 +279,19 @@ RADCLIENT *client_listener_find(rad_listen_t *listener,
 
        request->listener = listener;
        request->client = client;
-       request->packet = rad_recv(NULL, listener->fd, 0x02); /* MSG_PEEK */
+
+       request->packet = rad_alloc(request, false);
        if (!request->packet) {                         /* badly formed, etc */
                talloc_free(request);
                if (DEBUG_ENABLED) ERROR("Receive - %s", fr_strerror());
                goto unknown;
        }
-       (void) talloc_steal(request, request->packet);
+       request->packet->src_ipaddr = *ipaddr;
+       request->packet->src_port = src_port;
+       request->packet->dst_ipaddr = sock->my_ipaddr;
+       request->packet->dst_port = sock->my_port;
+       request->packet->proto = sock->proto;
+
        request->reply = rad_alloc_reply(request, request->packet);
        if (!request->reply) {
                talloc_free(request);