From: Vsevolod Stakhov Date: Thu, 31 May 2012 17:41:55 +0000 (+0400) Subject: Fix WSP canonization. X-Git-Tag: 0.5.0~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=21f28110c551ccb23e6706add70f62a9d166e54e;p=thirdparty%2Frspamd.git Fix WSP canonization. --- diff --git a/src/dkim.c b/src/dkim.c index c74222d3e7..a46596d6f0 100644 --- a/src/dkim.c +++ b/src/dkim.c @@ -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; }