From: Timo Sirainen Date: Thu, 9 Oct 2014 13:41:23 +0000 (+0300) Subject: lib-storage: Fixed header parsing when there were multiple same header names. X-Git-Tag: 2.2.14~33 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8b12e7b44abca3bd51a1c46e19ca504f3b55e723;p=thirdparty%2Fdovecot%2Fcore.git 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. --- diff --git a/src/lib-storage/index/index-mail-headers.c b/src/lib-storage/index/index-mail-headers.c index 3bc3fd8161..986949bfd3 100644 --- a/src/lib-storage/index/index-mail-headers.c +++ b/src/lib-storage/index/index-mail-headers.c @@ -71,6 +71,7 @@ static void index_mail_parse_header_finish(struct index_mail *mail) 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 @@ static void index_mail_parse_header_finish(struct index_mail *mail) 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; }