]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix processing of addresses in protocol
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 14 Jul 2016 17:45:26 +0000 (18:45 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 14 Jul 2016 17:45:26 +0000 (18:45 +0100)
Issue: #723
Reported by: @leoboiko

src/libserver/protocol.c

index d54f20d39232d3b293848aeb45a9fbc574982fef..de1e085926c72f9d301d60e43ea3e45d2e8fa8c9 100644 (file)
@@ -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);
 }