Commit 196cef2c authored by Niels Möller's avatar Niels Möller
Browse files

Fixed an fd leak in the server tcpip-forwarding code.

* src/tcpforward.c (do_tcpip_forward_request_continuation): Use
remember_resource to associate the bound fd to the connection.
(make_tcpip_forward_request_continuation): New argument,
connection.
(do_tcpip_forward_request): Pass the connection to
make_tcpip_forward_request_continuation.

Rev: src/tcpforward.c:1.66
parent 1b1a098e
......@@ -240,6 +240,7 @@ make_channel_open_direct_tcpip(struct command *callback)
(super command_continuation)
(vars
(forward object local_port)
(connection object ssh_connection)
(c object command_continuation)))
*/
......@@ -250,21 +251,26 @@ do_tcpip_forward_request_continuation(struct command_continuation *c,
CAST(tcpip_forward_request_continuation, self, c);
CAST(lsh_fd, fd, x);
trace("do_tcpip_forward_request_continuation\n");
assert(self->forward);
assert(fd);
self->forward->socket = fd;
remember_resource(self->connection->resources, &fd->super);
COMMAND_RETURN(self->c, &self->forward->super.super);
}
static struct command_continuation *
make_tcpip_forward_request_continuation(struct local_port *forward,
struct ssh_connection *connection,
struct command_continuation *c)
{
NEW(tcpip_forward_request_continuation, self);
trace("make_tcpip_forward_request_continuation\n");
self->forward = forward;
self->connection = connection;
self->c = c;
self->super.c = do_tcpip_forward_request_continuation;
......@@ -392,7 +398,9 @@ do_tcpip_forward_request(struct global_request *s,
{
COMMAND_CALL(self->callback,
a,
make_tcpip_forward_request_continuation(forward, c),
make_tcpip_forward_request_continuation(forward,
connection,
c),
make_tcpip_forward_request_exc(connection, forward,
e, HANDLER_CONTEXT));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment