Mercurial > dovecot > core-2.2
changeset 19624:259d971afa5a
pop3-migration: Filter out headers with invalid names.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Sun, 24 Jan 2016 19:34:21 +0200 |
parents | 7e08d7ae86be |
children | 0473b9d7e0fd |
files | src/plugins/pop3-migration/pop3-migration-plugin.c |
diffstat | 1 files changed, 16 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/pop3-migration/pop3-migration-plugin.c Sun Jan 24 19:23:59 2016 +0200 +++ b/src/plugins/pop3-migration/pop3-migration-plugin.c Sun Jan 24 19:34:21 2016 +0200 @@ -122,6 +122,17 @@ bool stop; }; +static bool header_name_is_valid(const char *name) +{ + unsigned int i; + + for (i = 0; name[i] != '\0'; i++) { + if ((uint8_t)name[i] <= 0x20 || name[i] >= 0x7f) + return FALSE; + } + return TRUE; +} + static void pop3_header_filter_callback(struct header_filter_istream *input ATTR_UNUSED, struct message_header_line *hdr, @@ -145,6 +156,11 @@ } if (ctx->stop) *matched = TRUE; + else if (!header_name_is_valid(hdr->name)) { + /* Yahoo IMAP drops headers with invalid names, while + Yahoo POP3 preserves them. Drop them all. */ + *matched = TRUE; + } } }