diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-05-19 16:45:31 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-05-19 16:45:31 +0100 |
commit | e72ca2d97d5c96ee5b9589e9a07782f276bb74b0 (patch) | |
tree | 95bc3bba64c98f5f0a7e4df0fd7b62d9cada3e50 /src | |
parent | f7054dc0b595e3ed714a5d859c049672aa2eba08 (diff) | |
download | rspamd-e72ca2d97d5c96ee5b9589e9a07782f276bb74b0.tar.gz rspamd-e72ca2d97d5c96ee5b9589e9a07782f276bb74b0.zip |
[Fix] Fix brain-damaged spamc protocol for now
Diffstat (limited to 'src')
-rw-r--r-- | src/libutil/http.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/libutil/http.c b/src/libutil/http.c index 194050980..80eff63d3 100644 --- a/src/libutil/http.c +++ b/src/libutil/http.c @@ -1843,10 +1843,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"); |