dovecot-2.2: lib-storage: Fixed header parsing when there were m...

dovecot at dovecot.org dovecot at dovecot.org
Thu Oct 9 13:42:04 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/0e1a3c909a13
changeset: 17917:0e1a3c909a13
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Oct 09 16:41:23 2014 +0300
description:
lib-storage: Fixed header parsing when there were multiple same header names.
For example if a mail had:

Name1: a
Name1: b
Name2: c

If the Name1: was initially added to cache and Name2: not, but later on both
were attempted to be added to cache, the Name2: lookup would have been added
with "b" instead of "c" value.

diffstat:

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

diffs (26 lines):

diff -r 90fbf199ebda -r 0e1a3c909a13 src/lib-storage/index/index-mail-headers.c
--- a/src/lib-storage/index/index-mail-headers.c	Thu Oct 09 12:02:21 2014 +0300
+++ b/src/lib-storage/index/index-mail-headers.c	Thu Oct 09 16:41:23 2014 +0300
@@ -71,6 +71,7 @@
 
 		if (match_idx < match_count) {
 			/* save index to first header line */
+			i_assert(match_idx == lines[i].field_idx);
 			j = i + 1;
 			array_idx_set(&mail->header_match_lines, match_idx, &j);
 			match_idx++;
@@ -78,8 +79,12 @@
 
 		if (!mail_cache_field_can_add(_mail->transaction->cache_trans,
 					      _mail->seq, lines[i].field_idx)) {
-			/* header is already cached */
-			j = i + 1;
+			/* header is already cached. skip over all the
+			   header lines. */
+			for (j = i+1; j < count; j++) {
+				if (lines[j].field_idx != lines[i].field_idx)
+					break;
+			}
 			continue;
 		}
 


More information about the dovecot-cvs mailing list