Skip to content

Commit

Permalink
Be more careful about talloc parent. Fixes #1129
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed Jul 8, 2015
1 parent 0b77881 commit 9e10a18
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
2 changes: 0 additions & 2 deletions src/main/listen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
20 changes: 6 additions & 14 deletions src/main/tls_listen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/*
Expand Down Expand Up @@ -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;
}

Expand All @@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down

0 comments on commit 9e10a18

Please sign in to comment.