BUG/MINOR: backend: free allocated bind_addr if reuse conn

Fix a leak in connect_server which happens when a connection is reused
and a bind_addr was allocated because transparent mode is active. The
connection has already an allocated bind_addr so free the newly
allocated one.

No backport needed.
This commit is contained in:
Amaury Denoyelle 2021-03-02 12:01:06 +01:00
parent 603657835f
commit 68967e595b

View File

@ -1506,19 +1506,24 @@ skip_reuse:
if (reuse_mode == PR_O_REUSE_NEVR)
conn_set_private(srv_conn);
/* assign bind_addr to srv_conn */
srv_conn->src = bind_addr;
bind_addr = NULL;
if (!sockaddr_alloc(&srv_conn->dst, 0, 0)) {
conn_free(srv_conn);
return SF_ERR_RESOURCE;
}
}
else {
sockaddr_free(&bind_addr);
return SF_ERR_RESOURCE;
}
}
/* if bind_addr is non NULL free it */
sockaddr_free(&bind_addr);
/* srv_conn is still NULL only on allocation failure */
if (!srv_conn)
return SF_ERR_RESOURCE;
/* copy the target address into the connection */
*srv_conn->dst = *s->target_addr;