Blame SOURCES/dovecot-2.2.10-0e1a3c909a13.patch

386c00
386c00
# HG changeset patch
386c00
# User Timo Sirainen <tss@iki.fi>
386c00
# Date 1412862083 -10800
386c00
# Node ID 0e1a3c909a137edd2ad2c133d71eee7f565265bf
386c00
# Parent  90fbf199ebdaeb3a3a4863f0897cbeec17a19105
386c00
lib-storage: Fixed header parsing when there were multiple same header names.
386c00
For example if a mail had:
386c00
386c00
Name1: a
386c00
Name1: b
386c00
Name2: c
386c00
386c00
If the Name1: was initially added to cache and Name2: not, but later on both
386c00
were attempted to be added to cache, the Name2: lookup would have been added
386c00
with "b" instead of "c" value.
386c00
386c00
diff -r 90fbf199ebda -r 0e1a3c909a13 src/lib-storage/index/index-mail-headers.c
386c00
--- a/src/lib-storage/index/index-mail-headers.c	Thu Oct 09 12:02:21 2014 +0300
386c00
+++ b/src/lib-storage/index/index-mail-headers.c	Thu Oct 09 16:41:23 2014 +0300
386c00
@@ -71,6 +71,7 @@
386c00
 
386c00
 		if (match_idx < match_count) {
386c00
 			/* save index to first header line */
386c00
+			i_assert(match_idx == lines[i].field_idx);
386c00
 			j = i + 1;
386c00
 			array_idx_set(&mail->header_match_lines, match_idx, &j);
386c00
 			match_idx++;
386c00
@@ -78,8 +79,12 @@
386c00
 
386c00
 		if (!mail_cache_field_can_add(_mail->transaction->cache_trans,
386c00
 					      _mail->seq, lines[i].field_idx)) {
386c00
-			/* header is already cached */
386c00
-			j = i + 1;
386c00
+			/* header is already cached. skip over all the
386c00
+			   header lines. */
386c00
+			for (j = i+1; j < count; j++) {
386c00
+				if (lines[j].field_idx != lines[i].field_idx)
386c00
+					break;
386c00
+			}
386c00
 			continue;
386c00
 		}
386c00
 
386c00