]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Fix truncating header values at NUL when adding to cache
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sat, 21 Apr 2018 11:31:08 +0000 (14:31 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 30 Aug 2018 08:12:03 +0000 (11:12 +0300)
For example FETCH BODY.PEEK[HEADER.FIELDS (Subject)] could have returned
the NUL on the first fetch when the mail wasn't in dovecot.index.cache,
but the second FETCH would have returned it truncated at the NUL.

src/lib-storage/index/index-mail-headers.c

index b57ac099bde1704e2028f777579a41bd9f6be02d..a9653646b689cdadc960efc4de99c120c0e0b3cb 100644 (file)
@@ -346,7 +346,7 @@ void index_mail_parse_header(struct message_part *part,
                   cache as nonexistent. */
                match[field_idx] |= HEADER_MATCH_FLAG_FOUND;
        }
-       str_append_n(mail->header_data, hdr->value, hdr->value_len);
+       str_append_data(mail->header_data, hdr->value, hdr->value_len);
        if (!hdr->no_newline)
                str_append(mail->header_data, "\n");
        if (!hdr->continues) {