Be more careful about talloc parent. Fixes #1129
authorAlan T. DeKok <aland@freeradius.org>
Wed, 8 Jul 2015 14:24:11 +0000 (10:24 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 8 Jul 2015 14:24:37 +0000 (10:24 -0400)
src/main/listen.c
src/main/tls_listen.c

index abb8e85..1532592 100644 (file)
@@ -2690,8 +2690,6 @@ static int _listener_free(rad_listen_t *this)
                rad_assert(talloc_parent(sock) == this);
                rad_assert(sock->ev == NULL);
 
-               rad_assert(!sock->packet || (talloc_parent(sock->packet) == sock));
-
                /*
                 *      Remove the child from the parent tree.
                 */
index d0c6c99..67db5d1 100644 (file)
@@ -139,9 +139,7 @@ static int tls_socket_recv(rad_listen_t *listener)
                sock->packet->dst_ipaddr = sock->my_ipaddr;
                sock->packet->dst_port = sock->my_port;
 
-               if (sock->request) {
-                       sock->request->packet = talloc_steal(sock->request, sock->packet);
-               }
+               if (sock->request) sock->request->packet = talloc_steal(sock->request, sock->packet);
        }
 
        /*
@@ -324,11 +322,6 @@ static int tls_socket_recv(rad_listen_t *listener)
 
        FR_STATS_INC(auth, total_requests);
 
-       /*
-        *      Re-parent the packet to nothing.
-        */
-       (void) talloc_steal(NULL, packet);
-
        return 1;
 }
 
@@ -350,7 +343,8 @@ int dual_tls_recv(rad_listen_t *listener)
        rad_assert(sock->ssn != NULL);
        rad_assert(client != NULL);
 
-       packet = sock->packet;
+       packet = talloc_steal(NULL, sock->packet);
+       sock->packet = NULL;
 
        /*
         *      Some sanity checks, based on the packet code.
@@ -386,7 +380,7 @@ int dual_tls_recv(rad_listen_t *listener)
                if (!main_config.status_server) {
                        FR_STATS_INC(auth, total_unknown_types);
                        WARN("Ignoring Status-Server request due to security configuration");
-                       rad_free(&sock->packet);
+                       rad_free(&packet);
                        return 0;
                }
                fun = rad_status_server;
@@ -398,18 +392,16 @@ int dual_tls_recv(rad_listen_t *listener)
 
                DEBUG("Invalid packet code %d sent from client %s port %d : IGNORED",
                      packet->code, client->shortname, packet->src_port);
-               rad_free(&sock->packet);
+               rad_free(&packet);
                return 0;
        } /* switch over packet types */
 
        if (!request_receive(NULL, listener, packet, client, fun)) {
                FR_STATS_INC(auth, total_packets_dropped);
-               rad_free(&sock->packet);
+               rad_free(&packet);
                return 0;
        }
 
-       sock->packet = NULL;    /* we have no need for more partial reads */
-
        return 1;
 }