]> source.dussan.org Git - rspamd.git/commitdiff
Fix processing of very short messages in DKIM.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 7 Nov 2014 17:08:41 +0000 (17:08 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 7 Nov 2014 17:08:41 +0000 (17:08 +0000)
Reported by: @citrin

src/libserver/dkim.c

index fb355d3531e1ab0c0ea6a5bf58a04106dcdac754..3c63e7280df6310116e52dcbd217df550766a26c 100644 (file)
@@ -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);