From e921a8559ccc890c0c0c6e283e61cf6d9e24c955 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 7 Nov 2014 17:08:41 +0000 Subject: Fix processing of very short messages in DKIM. Reported by: @citrin --- src/libserver/dkim.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libserver/dkim.c b/src/libserver/dkim.c index fb355d353..3c63e7280 100644 --- a/src/libserver/dkim.c +++ b/src/libserver/dkim.c @@ -1047,7 +1047,7 @@ rspamd_dkim_relaxed_body_step (GChecksum *ck, const gchar **start, guint size, t--; } /* Replace a single \n or \r with \r\n */ - if (*h == '\n' && h != *start && *(h - 1) != '\r') { + if (*h == '\n' && (h == *start || *(h - 1) != '\r')) { *t++ = '\r'; inlen--; added ++; @@ -1138,7 +1138,7 @@ rspamd_dkim_simple_body_step (GChecksum *ck, const gchar **start, guint size, while (len && inlen) { if (*h == '\r' || *h == '\n') { /* Replace a single \n or \r with \r\n */ - if (*h == '\n' && *(h - 1) != '\r') { + if (*h == '\n' && (h == *start || *(h - 1) != '\r')) { *t++ = '\r'; added ++; inlen--; @@ -1212,7 +1212,7 @@ rspamd_dkim_canonize_body (rspamd_dkim_context_t *ctx, } } end = p + 1; - if (end == start || end == start + 2) { + if (end == start) { /* Empty body */ if (ctx->body_canon_type == DKIM_CANON_SIMPLE) { g_checksum_update (ctx->body_hash, CRLF, sizeof (CRLF) - 1); -- cgit v1.2.3