From: Alan T. DeKok Date: Wed, 8 Jul 2015 14:24:11 +0000 (-0400) Subject: Be more careful about talloc parent. Fixes #1129 X-Git-Tag: release_3_0_9~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e10a182871cf1da79138b0300e9f2d134ef56cc;p=thirdparty%2Ffreeradius-server.git Be more careful about talloc parent. Fixes #1129 --- diff --git a/src/main/listen.c b/src/main/listen.c index abb8e857d69..15325922d72 100644 --- a/src/main/listen.c +++ b/src/main/listen.c @@ -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. */ diff --git a/src/main/tls_listen.c b/src/main/tls_listen.c index d0c6c999d77..67db5d1d2ed 100644 --- a/src/main/tls_listen.c +++ b/src/main/tls_listen.c @@ -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; }