commit ea381f5: [Minor] Improve http in milter mode error reporting
Vsevolod Stakhov
vsevolod at highsecure.ru
Thu Apr 2 13:00:10 UTC 2020
Author: Vsevolod Stakhov
Date: 2020-04-02 13:14:44 +0100
URL: https://github.com/rspamd/rspamd/commit/ea381f5f247e653e51222a24d097145056d5f4b9
[Minor] Improve http in milter mode error reporting
---
src/libserver/milter.c | 20 +++++++++++++++++---
1 file 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;
More information about the Commits
mailing list