diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-11-19 15:06:51 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-11-19 15:06:51 +0000 |
commit | ec2a5b3cf8392609a7cd9e40959238ba06d5806e (patch) | |
tree | 44af6675fe1973c4038297f1c7d9a322b2332d30 /src | |
parent | 55bf87c6af0cd32fb45de1e5c945f805f1c23d18 (diff) | |
download | rspamd-ec2a5b3cf8392609a7cd9e40959238ba06d5806e.tar.gz rspamd-ec2a5b3cf8392609a7cd9e40959238ba06d5806e.zip |
One more try to fix dkim border issues.
Diffstat (limited to 'src')
-rw-r--r-- | src/libserver/dkim.c | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/src/libserver/dkim.c b/src/libserver/dkim.c index b8b92700b..060620672 100644 --- a/src/libserver/dkim.c +++ b/src/libserver/dkim.c @@ -1027,11 +1027,8 @@ rspamd_dkim_relaxed_body_step (GChecksum *ck, const gchar **start, guint size, guint len, inlen, added = 0; gboolean got_sp, finished = FALSE; - if (size > sizeof (buf)) { - len = sizeof (buf); - } - else { - len = size; + len = size; + if (size <= sizeof (buf)) { finished = TRUE; } inlen = sizeof (buf) - 1; @@ -1046,6 +1043,15 @@ rspamd_dkim_relaxed_body_step (GChecksum *ck, const gchar **start, guint size, got_sp = FALSE; t--; } + if (inlen < 2) { + /* + * Inlen is too small to continue, hence we need more iteration to + * avoid splitted \r\n + */ + h --; + finished = FALSE; + break; + } /* Replace a single \n or \r with \r\n */ if (*h == '\n' && (h == *start || *(h - 1) != '\r')) { *t++ = '\r'; @@ -1069,14 +1075,6 @@ rspamd_dkim_relaxed_body_step (GChecksum *ck, const gchar **start, guint size, len--; continue; } - else if (inlen < 2) { - /* - * Inlen is too small to continue, hence we need more iteration to - * avoid splitted \r\n - */ - finished = FALSE; - break; - } } else if (g_ascii_isspace (*h)) { if (got_sp) { @@ -1136,11 +1134,8 @@ rspamd_dkim_simple_body_step (GChecksum *ck, const gchar **start, guint size, guint len, inlen, added = 0; gboolean finished = FALSE; - if (size > sizeof (buf)) { - len = sizeof (buf); - } - else { - len = size; + len = size; + if (size <= sizeof (buf)) { finished = TRUE; } inlen = sizeof (buf) - 1; @@ -1149,6 +1144,15 @@ rspamd_dkim_simple_body_step (GChecksum *ck, const gchar **start, guint size, while (len && inlen) { if (*h == '\r' || *h == '\n') { + if (inlen < 2) { + /* + * Inlen is too small to continue, hence we need more iteration to + * avoid splitted \r\n + */ + h --; + finished = FALSE; + break; + } /* Replace a single \n or \r with \r\n */ if (*h == '\n' && (h == *start || *(h - 1) != '\r')) { *t++ = '\r'; @@ -1169,14 +1173,6 @@ rspamd_dkim_simple_body_step (GChecksum *ck, const gchar **start, guint size, len--; continue; } - else if (inlen < 2) { - /* - * Inlen is too small to continue, hence we need more iteration to - * avoid splitted \r\n - */ - finished = FALSE; - break; - } } *t++ = *h++; inlen--; |