diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-05-07 14:00:17 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-05-07 14:05:12 +0100 |
commit | 103ea0a9b96fe899eb01cefe2bbdff01f86e23f6 (patch) | |
tree | f916f11e5a2a2cdaf4e5c174404d03722a152e9a /src | |
parent | ce12e4e392eb70b1f9b35597c297dbbf8330fc04 (diff) | |
download | rspamd-103ea0a9b96fe899eb01cefe2bbdff01f86e23f6.tar.gz rspamd-103ea0a9b96fe899eb01cefe2bbdff01f86e23f6.zip |
[Minor] Fix leaks and corruption in milter interface
Diffstat (limited to 'src')
-rw-r--r-- | src/rspamd_proxy.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/rspamd_proxy.c b/src/rspamd_proxy.c index 5edd682e5..48c8da67a 100644 --- a/src/rspamd_proxy.c +++ b/src/rspamd_proxy.c @@ -1273,6 +1273,7 @@ proxy_backend_master_finish_handler (struct rspamd_http_connection *conn, rspamd_milter_send_action (nsession->client_milter_conn, RSPAMD_MILTER_ACCEPT); REF_RELEASE (session); + rspamd_http_message_free (msg); } else { rspamd_http_connection_write_message (session->client_conn, @@ -1288,7 +1289,7 @@ rspamd_proxy_scan_self_reply (struct rspamd_task *task) { struct rspamd_http_message *msg; struct rspamd_proxy_session *session = task->fin_arg, *nsession; - ucl_object_t *rep; + ucl_object_t *rep = NULL; const char *ctype = "application/json"; msg = rspamd_http_new_message (HTTP_RESPONSE); @@ -1316,7 +1317,10 @@ rspamd_proxy_scan_self_reply (struct rspamd_task *task) } session->master_conn->flags |= RSPAMD_BACKEND_CLOSED; - session->master_conn->results = rep; + + if (rep) { + session->master_conn->results = ucl_object_ref (rep); + } if (session->client_milter_conn) { /* @@ -1325,6 +1329,7 @@ rspamd_proxy_scan_self_reply (struct rspamd_task *task) nsession = proxy_session_refresh (session); rspamd_milter_send_action (nsession->client_milter_conn, RSPAMD_MILTER_ACCEPT); + rspamd_http_message_free (msg); REF_RELEASE (session); } else { @@ -1378,7 +1383,15 @@ rspamd_proxy_self_scan (struct rspamd_proxy_session *session) task = rspamd_task_new (session->worker, session->ctx->cfg); task->flags |= RSPAMD_TASK_FLAG_MIME; task->sock = -1; - task->client_addr = session->client_addr; + + if (session->client_milter_conn) { + task->client_addr = rspamd_inet_address_copy ( + session->client_milter_conn->addr); + } + else { + task->client_addr = rspamd_inet_address_copy (session->client_addr); + } + task->fin_arg = session; task->resolver = session->ctx->resolver; /* TODO: allow to disable autolearn in protocol */ @@ -1416,6 +1429,7 @@ rspamd_proxy_self_scan (struct rspamd_proxy_session *session) event_add (&task->timeout_ev, &task_tv); } + session->master_conn->task = task; rspamd_task_process (task, RSPAMD_TASK_PROCESS_ALL); return TRUE; |