aboutsummaryrefslogtreecommitdiffstats
path: root/src/client/rspamdclient.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-05-07 20:55:31 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-05-07 20:55:31 +0100
commit8dfc00bbb4df3bff774eecc806128d09579a7f80 (patch)
tree4980126c76cbe8944f58726f7a89e3dfeff9bd3d /src/client/rspamdclient.c
parent35e67fa3f01c3057af094168df00aa5153827de8 (diff)
downloadrspamd-8dfc00bbb4df3bff774eecc806128d09579a7f80.tar.gz
rspamd-8dfc00bbb4df3bff774eecc806128d09579a7f80.zip
[Fix] Fix sockets leak in the client
Issue: #3328
Diffstat (limited to 'src/client/rspamdclient.c')
-rw-r--r--src/client/rspamdclient.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/client/rspamdclient.c b/src/client/rspamdclient.c
index e8c0b959c..e65a6935c 100644
--- a/src/client/rspamdclient.c
+++ b/src/client/rspamdclient.c
@@ -279,7 +279,15 @@ rspamd_client_init (struct rspamd_http_context *http_ctx,
0,
fd);
+ if (!conn->http_conn) {
+ rspamd_client_destroy (conn);
+ return NULL;
+ }
+
+ /* Pass socket ownership */
+ rspamd_http_connection_own_socket (conn);
conn->server_name = g_string_new (name);
+
if (port != 0) {
rspamd_printf_gstring (conn->server_name, ":%d", (int)port);
}
@@ -474,7 +482,10 @@ void
rspamd_client_destroy (struct rspamd_client_connection *conn)
{
if (conn != NULL) {
- rspamd_http_connection_unref (conn->http_conn);
+ if (conn->http_conn) {
+ rspamd_http_connection_unref (conn->http_conn);
+ }
+
if (conn->req != NULL) {
rspamd_client_request_free (conn->req);
}
@@ -482,9 +493,11 @@ rspamd_client_destroy (struct rspamd_client_connection *conn)
if (conn->key) {
rspamd_pubkey_unref (conn->key);
}
+
if (conn->keypair) {
rspamd_keypair_unref (conn->keypair);
}
+
g_string_free (conn->server_name, TRUE);
g_free (conn);
}