]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
fts: Fix indexing mails with NULs in headers
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 23 Aug 2018 11:33:59 +0000 (14:33 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 30 Aug 2018 08:25:14 +0000 (11:25 +0300)
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

src/plugins/fts/fts-build-mail.c

index b9689b084a461ed26902843b107205d7cb901e9b..bd6729573a9b0943a4f3d5c340a88d31267008f0 100644 (file)
@@ -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);