From: Timo Sirainen Date: Thu, 23 Aug 2018 11:33:59 +0000 (+0300) Subject: fts: Fix indexing mails with NULs in headers X-Git-Tag: 2.3.4~230 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a318cf4ac628dce0f0ffcb459cf11165ed8c792b;p=thirdparty%2Fdovecot%2Fcore.git fts: Fix indexing mails with NULs in headers After the first NUL all the rest of the string was converted to spaces. This was broken already in the initial commit that attempted to fix this: 4d27f95c76bd008bb38f9c442567046da2b6ce14 --- diff --git a/src/plugins/fts/fts-build-mail.c b/src/plugins/fts/fts-build-mail.c index b9689b084a..bd6729573a 100644 --- a/src/plugins/fts/fts-build-mail.c +++ b/src/plugins/fts/fts-build-mail.c @@ -91,15 +91,15 @@ fts_build_unstructured_header(struct fts_mail_build_context *ctx, /* @UNSAFE: if there are any NULs, replace them with spaces */ for (i = 0; i < hdr->full_value_len; i++) { - if (data[i] == '\0') { + if (hdr->full_value[i] == '\0') { if (buf == NULL) { buf = i_malloc(hdr->full_value_len); - memcpy(buf, data, i); + memcpy(buf, hdr->full_value, i); data = buf; } buf[i] = ' '; } else if (buf != NULL) { - buf[i] = data[i]; + buf[i] = hdr->full_value[i]; } } ret = fts_build_data(ctx, data, hdr->full_value_len, TRUE);