]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: proto_reverse_connect: fix FD leak upon connect
authorWilliam Lallemand <wlallemand@haproxy.org>
Fri, 29 Sep 2023 22:53:43 +0000 (00:53 +0200)
committerWilliam Lallemand <wlallemand@haproxy.org>
Fri, 29 Sep 2023 22:53:43 +0000 (00:53 +0200)
new_reverse_conn() is creating its own socket with
sock_create_server_socket(). However the connect is done with
conn->ctrl->connect() which is tcp_connect_server().

tcp_connect_server() is also creating its own socket and sets it in the
struct conn, left the previous socket unclosed and leaking at each
attempt.

This patch fixes the issue by letting tcp_connect_server() handling the
socket part, and removes it in new_reverse_conn().

src/proto_reverse_connect.c

index 1649a69dfa60870e8fa6de4e42966e0bd9fed0aa..61cf448065556f91b8a7e99b1816ec90eaf22a81 100644 (file)
@@ -68,11 +68,6 @@ static struct connection *new_reverse_conn(struct listener *l, struct server *sr
        if (conn_prepare(conn, protocol_lookup(conn->dst->ss_family, PROTO_TYPE_STREAM, 0), srv->xprt))
                goto err;
 
-       /* TODO simplification of tcp_connect_server() */
-       conn->handle.fd = sock_create_server_socket(conn);
-       if (fd_set_nonblock(conn->handle.fd) == -1)
-               goto err;
-
        if (conn->ctrl->connect(conn, 0) != SF_ERR_NONE)
                goto err;