]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Fix WSP canonization.
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Thu, 31 May 2012 17:41:55 +0000 (21:41 +0400)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Thu, 31 May 2012 17:41:55 +0000 (21:41 +0400)
src/dkim.c

index c74222d3e771d0486f0f34dc433f3a280beb4620..a46596d6f0eaa05beb7bf70e1afd736891ed293c 100644 (file)
@@ -765,7 +765,12 @@ rspamd_dkim_relaxed_body_step (GChecksum *ck, const gchar **start, guint remain)
                                continue;
                        }
                        else {
+                               *t++ = ' ';
+                               h ++;
+                               inlen --;
+                               len --;
                                got_sp = TRUE;
+                               continue;
                        }
                }
                else {
@@ -778,6 +783,9 @@ rspamd_dkim_relaxed_body_step (GChecksum *ck, const gchar **start, guint remain)
 
        *start = h;
 
+       /* Maybe extremely slow
+        * msg_debug ("update signature with buffer: %*s", t - buf, buf);
+        */
        g_checksum_update (ck, buf, t - buf);
 
        return !finished;
@@ -862,7 +870,8 @@ rspamd_dkim_signature_update (rspamd_dkim_context_t *ctx, const gchar *begin, gu
        while ((*p == '\r' || *p == '\n') && p >= c) {
                p --;
        }
-       if (p - c > 0) {
+
+       if (p - c + 1 > 0) {
                msg_debug ("final update hash with signature part: %*s", p - c + 1, c);
                g_checksum_update (ctx->headers_hash, c, p - c + 1);
        }
@@ -872,7 +881,7 @@ static gboolean
 rspamd_dkim_canonize_header_relaxed (rspamd_dkim_context_t *ctx, const gchar *header, const gchar *header_name, gboolean is_sign)
 {
        const gchar                                                                     *h;
-       gchar                                                                           *t, *buf, *v;
+       gchar                                                                           *t, *buf;
        guint                                                                            inlen;
        gboolean                                                                         got_sp, allocated = FALSE;
 
@@ -895,7 +904,6 @@ rspamd_dkim_canonize_header_relaxed (rspamd_dkim_context_t *ctx, const gchar *he
        *t++ = ':';
 
        /* Value part */
-       v = t;
        h = header;
        got_sp = FALSE;
 
@@ -907,6 +915,9 @@ rspamd_dkim_canonize_header_relaxed (rspamd_dkim_context_t *ctx, const gchar *he
                        }
                        else {
                                got_sp = TRUE;
+                               *t ++ = ' ';
+                               h ++;
+                               continue;
                        }
                }
                else {
@@ -1017,7 +1028,12 @@ rspamd_dkim_canonize_header (rspamd_dkim_context_t *ctx, struct worker_task *tas
                                if (! rspamd_dkim_canonize_header_relaxed (ctx, rh->value, header_name, is_sig)) {
                                        return FALSE;
                                }
-                               rh = rh->next;
+                               if (!is_sig) {
+                                       rh = rh->next;
+                               }
+                               else {
+                                       rh = NULL;
+                               }
                        }
                        return TRUE;
                }