From: Vsevolod Stakhov Date: Tue, 27 Feb 2018 16:37:44 +0000 (+0000) Subject: [CritFix] Do not send reject messages after set reply X-Git-Tag: 1.7.0~109 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2bda2989eee893c42ff04f48a904f00a33a7d07a;p=rspamd.git [CritFix] Do not send reject messages after set reply Libmilter seems to be totally brain damaged: https://github.com/freebsd/freebsd/blob/386ddae58459341ec567604707805814a2128a57/contrib/sendmail/libmilter/engine.c#L663 --- diff --git a/src/libserver/milter.c b/src/libserver/milter.c index 628e1aa3e..fed948f0b 100644 --- a/src/libserver/milter.c +++ b/src/libserver/milter.c @@ -102,6 +102,8 @@ rspamd_milter_session_reset (struct rspamd_milter_session *session, guint i; if (how & RSPAMD_MILTER_RESET_IO) { + msg_debug_milter ("cleanup IO on abort"); + DL_FOREACH_SAFE (priv->out_chain, obuf, obuf_tmp) { rspamd_milter_obuf_free (obuf); } @@ -114,8 +116,11 @@ rspamd_milter_session_reset (struct rspamd_milter_session *session, } if (how & RSPAMD_MILTER_RESET_COMMON) { + msg_debug_milter ("cleanup common data on abort"); + if (session->message) { session->message->len = 0; + msg_debug_milter ("cleanup message on abort"); } if (session->rcpts) { @@ -123,30 +128,38 @@ rspamd_milter_session_reset (struct rspamd_milter_session *session, rspamd_email_address_free (cur); } + msg_debug_milter ("cleanup %d recipients on abort", + (gint)session->rcpts->len); + g_ptr_array_free (session->rcpts, TRUE); session->rcpts = NULL; } if (session->from) { + msg_debug_milter ("cleanup from"); rspamd_email_address_free (session->from); session->from = NULL; } if (session->helo) { + msg_debug_milter ("cleanup helo"); session->helo->len = 0; } if (session->hostname) { + msg_debug_milter ("cleanup hostname"); session->hostname->len = 0; } if (priv->headers) { + msg_debug_milter ("cleanup headers"); g_hash_table_remove_all (priv->headers); } } if (how & RSPAMD_MILTER_RESET_ADDR) { if (session->addr) { + msg_debug_milter ("cleanup addr"); rspamd_inet_address_free (session->addr); session->addr = NULL; } @@ -154,6 +167,7 @@ rspamd_milter_session_reset (struct rspamd_milter_session *session, if (how & RSPAMD_MILTER_RESET_MACRO) { if (session->macros) { + msg_debug_milter ("cleanup macros"); g_hash_table_unref (session->macros); session->macros = NULL; } @@ -1671,7 +1685,7 @@ rspamd_milter_send_task_results (struct rspamd_milter_session *session, msg_err_milter ("cannot find scan results, tempfail"); rspamd_milter_send_action (session, RSPAMD_MILTER_TEMPFAIL); - return; + goto cleanup; } elt = ucl_object_lookup (results, "action"); @@ -1680,7 +1694,7 @@ rspamd_milter_send_task_results (struct rspamd_milter_session *session, msg_err_milter ("cannot find action in results, tempfail"); rspamd_milter_send_action (session, RSPAMD_MILTER_TEMPFAIL); - return; + goto cleanup; } str_action = ucl_object_tostring (elt); @@ -1761,7 +1775,6 @@ rspamd_milter_send_task_results (struct rspamd_milter_session *session, } rspamd_milter_set_reply (session, rcode, xcode, reply); - rspamd_milter_send_action (session, RSPAMD_MILTER_REJECT); } break; case METRIC_ACTION_SOFT_REJECT: @@ -1776,7 +1789,6 @@ rspamd_milter_send_task_results (struct rspamd_milter_session *session, } rspamd_milter_set_reply (session, rcode, xcode, reply); - rspamd_milter_send_action (session, RSPAMD_MILTER_REJECT); break; case METRIC_ACTION_REWRITE_SUBJECT: @@ -1821,6 +1833,8 @@ cleanup: rspamd_fstring_free (rcode); rspamd_fstring_free (xcode); rspamd_fstring_free (reply); + + rspamd_milter_session_reset (session, RSPAMD_MILTER_RESET_ABORT); } void