aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-11-05 15:27:34 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-11-05 15:27:34 +0000
commitbb727f7e43e6a944a174667cf76806860824691b (patch)
tree414a9f8c4616c804f7c77189feb904a91c027da3 /src/libserver
parente4561898f82b6d1bdfd81592ce3232b094f1edb2 (diff)
downloadrspamd-bb727f7e43e6a944a174667cf76806860824691b.tar.gz
rspamd-bb727f7e43e6a944a174667cf76806860824691b.zip
Fix \r\n conversion in DKIM module.
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/dkim.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/libserver/dkim.c b/src/libserver/dkim.c
index f0d4bfd13..55b7cd331 100644
--- a/src/libserver/dkim.c
+++ b/src/libserver/dkim.c
@@ -1024,7 +1024,7 @@ rspamd_dkim_relaxed_body_step (GChecksum *ck, const gchar **start, guint size,
const gchar *h;
static gchar buf[BUFSIZ];
gchar *t;
- guint len, inlen;
+ guint len, inlen, added = 0;
gboolean got_sp, finished = FALSE;
if (size > sizeof (buf)) {
@@ -1050,6 +1050,7 @@ rspamd_dkim_relaxed_body_step (GChecksum *ck, const gchar **start, guint size,
if (*h == '\n' && h != *start && *(h - 1) != '\r') {
*t++ = '\r';
inlen--;
+ added ++;
if (inlen == 0) {
break;
}
@@ -1057,6 +1058,7 @@ rspamd_dkim_relaxed_body_step (GChecksum *ck, const gchar **start, guint size,
else if (*h == '\r' && *(h + 1) != '\n') {
*t++ = *h++;
*t++ = '\n';
+ added ++;
if (inlen > 1) {
inlen -= 2;
}
@@ -1102,7 +1104,7 @@ rspamd_dkim_relaxed_body_step (GChecksum *ck, const gchar **start, guint size,
if (*remain > 0) {
size_t cklen = MIN(t - buf, *remain);
g_checksum_update (ck, buf, cklen);
- *remain = *remain - cklen;
+ *remain = *remain - (cklen - added);
#if 0
msg_debug ("update signature with buffer (%ud size, %ud remain): %*s",
cklen, *remain, cklen, buf);
@@ -1119,7 +1121,7 @@ rspamd_dkim_simple_body_step (GChecksum *ck, const gchar **start, guint size,
const gchar *h;
static gchar buf[BUFSIZ];
gchar *t;
- guint len, inlen;
+ guint len, inlen, added = 0;
gboolean finished = FALSE;
if (size > sizeof (buf)) {
@@ -1138,10 +1140,12 @@ rspamd_dkim_simple_body_step (GChecksum *ck, const gchar **start, guint size,
/* Replace a single \n or \r with \r\n */
if (*h == '\n' && *(h - 1) != '\r') {
*t++ = '\r';
+ added ++;
inlen--;
}
else if (*h == '\r' && *(h + 1) != '\n') {
*t++ = *h++;
+ added ++;
*t++ = '\n';
if (inlen > 1) {
inlen -= 2;
@@ -1167,7 +1171,7 @@ rspamd_dkim_simple_body_step (GChecksum *ck, const gchar **start, guint size,
if (*remain > 0) {
size_t cklen = MIN(t - buf, *remain);
g_checksum_update (ck, buf, cklen);
- *remain = *remain - cklen;
+ *remain = *remain - (cklen - added);
}
return !finished;