From: Vsevolod Stakhov Date: Thu, 14 Jul 2016 17:45:26 +0000 (+0100) Subject: [Fix] Fix processing of addresses in protocol X-Git-Tag: 1.3.0~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=356f35cb0707181811bbb43fb56bc6d1bfdde866;p=thirdparty%2Frspamd.git [Fix] Fix processing of addresses in protocol Issue: #723 Reported by: @leoboiko --- diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index d54f20d392..de1e085926 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -112,6 +112,7 @@ rspamd_protocol_escape_braces (struct rspamd_task *task, rspamd_fstring_t *in) guint nchars = 0; const gchar *p; rspamd_ftok_t tok; + gboolean has_obrace = FALSE; g_assert (in != NULL); g_assert (in->len > 0); @@ -119,6 +120,10 @@ rspamd_protocol_escape_braces (struct rspamd_task *task, rspamd_fstring_t *in) p = in->str; while ((g_ascii_isspace (*p) || *p == '<') && nchars < in->len) { + if (*p == '<') { + has_obrace = TRUE; + } + p++; nchars ++; } @@ -128,12 +133,15 @@ rspamd_protocol_escape_braces (struct rspamd_task *task, rspamd_fstring_t *in) p = in->str + in->len - 1; tok.len = in->len - nchars; - while ((!g_ascii_isspace (*p) && *p != - '>') && tok.len > 0) { + while (g_ascii_isspace (*p) && tok.len > 0) { p--; tok.len --; } + if (has_obrace && *p == '>') { + tok.len --; + } + return rspamd_mempool_ftokdup (task->task_pool, &tok); }