dovecot-2.2: lib-storage: Headers were sometimes added to doveco...

dovecot at dovecot.org dovecot at dovecot.org
Wed Sep 24 21:44:06 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/6d4e7ccb24ea
changeset: 17832:6d4e7ccb24ea
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Sep 25 00:42:56 2014 +0300
description:
lib-storage: Headers were sometimes added to dovecot.index.cache with wrong line number value.
This happened if the header parsing was done multiple times for the same
mail. The end result being that when fetching multiple headers as a stream,
the headers could have been returned in the wrong order. This messed up at
least dsync's header hash comparisons.

diffstat:

 src/lib-storage/index/index-mail-headers.c |  6 ++++++
 src/lib-storage/index/index-mail.h         |  1 +
 2 files changed, 7 insertions(+), 0 deletions(-)

diffs (41 lines):

diff -r 47ffe55be1ed -r 6d4e7ccb24ea src/lib-storage/index/index-mail-headers.c
--- a/src/lib-storage/index/index-mail-headers.c	Thu Sep 25 00:41:15 2014 +0300
+++ b/src/lib-storage/index/index-mail-headers.c	Thu Sep 25 00:42:56 2014 +0300
@@ -130,6 +130,7 @@
 	}
 
 	mail->data.dont_cache_field_idx = UINT_MAX;
+	mail->data.header_parser_initialized = FALSE;
 }
 
 static unsigned int
@@ -247,6 +248,9 @@
 		array_idx_set(&mail->header_match, field_idx,
 			      &mail->header_match_value);
 	}
+	mail->data.header_parser_initialized = TRUE;
+	mail->data.parse_line_num = 0;
+	memset(&mail->data.parse_line, 0, sizeof(mail->data.parse_line));
 }
 
 static void index_mail_parse_finish_imap_envelope(struct index_mail *mail)
@@ -276,6 +280,8 @@
 	unsigned int field_idx, count;
 	uint8_t *match;
 
+	i_assert(data->header_parser_initialized);
+
         data->parse_line_num++;
 
 	if (data->save_bodystructure_header) {
diff -r 47ffe55be1ed -r 6d4e7ccb24ea src/lib-storage/index/index-mail.h
--- a/src/lib-storage/index/index-mail.h	Thu Sep 25 00:41:15 2014 +0300
+++ b/src/lib-storage/index/index-mail.h	Thu Sep 25 00:42:56 2014 +0300
@@ -126,6 +126,7 @@
 	unsigned int initialized_wrapper_stream:1;
 	unsigned int destroy_callback_set:1;
 	unsigned int prefetch_sent:1;
+	unsigned int header_parser_initialized:1;
 };
 
 struct index_mail {


More information about the dovecot-cvs mailing list