]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Improve http in milter mode error reporting
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 2 Apr 2020 12:14:44 +0000 (13:14 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 2 Apr 2020 12:14:44 +0000 (13:14 +0100)
src/libserver/milter.c

index 26e1fd1cdb0d988a60cb40a6c2e2eaa9398947cb..dc398912d0d3610f373cffbe70b845130ca82bcd 100644 (file)
@@ -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;