dovecot-2.2: dsync: When doing a header-based sync, convert all ...

dovecot at dovecot.org dovecot at dovecot.org
Mon Feb 11 01:11:04 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/d73d04e24eee
changeset: 15752:d73d04e24eee
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Feb 11 01:07:53 2013 +0200
description:
dsync: When doing a header-based sync, convert all linefeeds to LFs.
Fixes syncing where one side used CRLFs and the other side used LFs.

diffstat:

 src/doveadm/dsync/dsync-mail.c |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (43 lines):

diff -r 45c39743f406 -r d73d04e24eee src/doveadm/dsync/dsync-mail.c
--- a/src/doveadm/dsync/dsync-mail.c	Mon Feb 11 00:29:40 2013 +0200
+++ b/src/doveadm/dsync/dsync-mail.c	Mon Feb 11 01:07:53 2013 +0200
@@ -5,6 +5,7 @@
 #include "hex-binary.h"
 #include "md5.h"
 #include "istream.h"
+#include "istream-crlf.h"
 #include "message-size.h"
 #include "mail-storage.h"
 #include "dsync-mail.h"
@@ -19,7 +20,7 @@
 
 int dsync_mail_get_hdr_hash(struct mail *mail, const char **hdr_hash_r)
 {
-	struct istream *input;
+	struct istream *hdr_input, *input;
 	struct mailbox_header_lookup_ctx *hdr_ctx;
 	struct md5_context md5_ctx;
 	unsigned char md5_result[MD5_RESULTLEN];
@@ -28,11 +29,13 @@
 	int ret = 0;
 
 	hdr_ctx = mailbox_header_lookup_init(mail->box, hashed_headers);
-	ret = mail_get_header_stream(mail, hdr_ctx, &input);
+	ret = mail_get_header_stream(mail, hdr_ctx, &hdr_input);
 	mailbox_header_lookup_unref(&hdr_ctx);
 	if (ret < 0)
 		return -1;
 
+	input = i_stream_create_lf(hdr_input);
+
 	md5_init(&md5_ctx);
 	while (!i_stream_is_eof(input)) {
 		if (i_stream_read_data(input, &data, &size, 0) == -1)
@@ -44,6 +47,7 @@
 	}
 	if (input->stream_errno != 0)
 		ret = -1;
+	i_stream_unref(&input);
 
 	md5_final(&md5_ctx, md5_result);
 	*hdr_hash_r = binary_to_hex(md5_result, sizeof(md5_result));


More information about the dovecot-cvs mailing list