]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix brain-damaged spamc protocol for now
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 19 May 2017 15:45:31 +0000 (16:45 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 20 May 2017 11:31:41 +0000 (12:31 +0100)
src/libutil/http.c

index 24c5e730c09cbec9864c5686352055be1cd394bd..e5ff95f32c0340ee424fc996f91b68b76cc0d031 100644 (file)
@@ -1813,10 +1813,25 @@ rspamd_http_message_write_header (const gchar* mime_type, gboolean encrypted,
                else {
                        /* Legacy spamd reply */
                        if (msg->flags & RSPAMD_HTTP_FLAG_SPAMC) {
+                               gsize real_bodylen;
+                               goffset eoh_pos;
+                               GString tmp;
+
+                               /* Unfortunately, spamc protocol is deadly brain damaged */
+                               tmp.str = (gchar *)msg->body_buf.begin;
+                               tmp.len = msg->body_buf.len;
+
+                               if (rspamd_string_find_eoh (&tmp, &eoh_pos) != -1 &&
+                                               bodylen > eoh_pos) {
+                                       real_bodylen = bodylen - eoh_pos;
+                               }
+                               else {
+                                       real_bodylen = bodylen;
+                               }
+
                                rspamd_printf_fstring (buf, "SPAMD/1.1 0 EX_OK\r\n"
-                                               "Content-length: %z\r\n"
-                                               "\r\n",
-                                               bodylen);
+                                               "Content-length: %z\r\n",
+                                               real_bodylen);
                        }
                        else {
                                rspamd_printf_fstring (buf, "RSPAMD/1.3 0 EX_OK\r\n");