From: Vsevolod Stakhov Date: Fri, 7 Nov 2014 17:08:41 +0000 (+0000) Subject: Fix processing of very short messages in DKIM. X-Git-Tag: 0.7.4~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e921a8559ccc890c0c0c6e283e61cf6d9e24c955;p=thirdparty%2Frspamd.git Fix processing of very short messages in DKIM. Reported by: @citrin --- diff --git a/src/libserver/dkim.c b/src/libserver/dkim.c index fb355d3531..3c63e7280d 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);