diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-04-02 13:14:44 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-04-02 13:14:44 +0100 |
commit | ea381f5f247e653e51222a24d097145056d5f4b9 (patch) | |
tree | b422e8063aba5d6ffd127f0734931b750a94df01 | |
parent | 76a1fb06de1fca871ed223eb4306daa7ee7cfb1c (diff) | |
download | rspamd-ea381f5f247e653e51222a24d097145056d5f4b9.tar.gz rspamd-ea381f5f247e653e51222a24d097145056d5f4b9.zip |
[Minor] Improve http in milter mode error reporting
-rw-r--r-- | src/libserver/milter.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/libserver/milter.c b/src/libserver/milter.c index 26e1fd1cd..dc398912d 100644 --- a/src/libserver/milter.c +++ b/src/libserver/milter.c @@ -847,9 +847,23 @@ rspamd_milter_consume_input (struct rspamd_milter_session *session, /* We might need some more data in buffer for further steps */ if (priv->parser.datalen > RSPAMD_MILTER_MESSAGE_CHUNK * 2) { - err = g_error_new (rspamd_milter_quark (), E2BIG, - "Command length is too big: %zd", - priv->parser.datalen); + /* Check if we have HTTP input instead of milter */ + if (priv->parser.buf->len > sizeof ("GET") && + memcmp (priv->parser.buf->str, "GET", 3) == 0) { + err = g_error_new (rspamd_milter_quark (), EINVAL, + "HTTP GET request is not supported in milter mode"); + } + else if (priv->parser.buf->len > sizeof ("POST") && + memcmp (priv->parser.buf->str, "POST", 4) == 0) { + err = g_error_new (rspamd_milter_quark (), EINVAL, + "HTTP POST request is not supported in milter mode"); + } + else { + err = g_error_new (rspamd_milter_quark (), E2BIG, + "Command length is too big: %zd", + priv->parser.datalen); + } + rspamd_milter_on_protocol_error (session, priv, err); return FALSE; |