From: Timo Sirainen Date: Mon, 3 Feb 2014 15:49:03 +0000 (-0500) Subject: pop3-migration: Convert NULs to 0x80 chars in header when hashing. X-Git-Tag: 2.2.11~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8c3872c26b18421d62c52cbfe0b81b1d79239f89;p=thirdparty%2Fdovecot%2Fcore.git pop3-migration: Convert NULs to 0x80 chars in header when hashing. This should help at least with Dovecot and I think also with UW-IMAP/POP3. --- diff --git a/src/plugins/pop3-migration/pop3-migration-plugin.c b/src/plugins/pop3-migration/pop3-migration-plugin.c index cf1c07bace..0f0c77534d 100644 --- a/src/plugins/pop3-migration/pop3-migration-plugin.c +++ b/src/plugins/pop3-migration/pop3-migration-plugin.c @@ -142,6 +142,17 @@ get_hdr_sha1_stream(struct mail *mail, struct istream *input, uoff_t hdr_size, sha1_init(&sha1_ctx); while (i_stream_read_data(input, &data, &size, 0) > 0) { + /* if there are NULs in header, replace them with 0x80 + character. This is done by at least Dovecot IMAP and also + POP3 with outlook-no-nuls workaround. */ + while ((p = memchr(data, '\0', size)) != NULL) { + idx = p - data; + sha1_loop(&sha1_ctx, data, idx); + sha1_loop(&sha1_ctx, "\x80", 1); + i_assert(size > idx); + data += idx + 1; + size -= idx + 1; + } sha1_loop(&sha1_ctx, data, size); i_stream_skip(input, size); }