]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
pop3-migration: Filter out headers with invalid names.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 24 Jan 2016 17:34:21 +0000 (19:34 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 24 Jan 2016 17:34:21 +0000 (19:34 +0200)
src/plugins/pop3-migration/pop3-migration-plugin.c

index fbebb79645a5754c3d44937a085a657a12c57464..055d17edc6fb1de3adf8e4c68ead942dd8206c20 100644 (file)
@@ -122,6 +122,17 @@ struct pop3_hdr_context {
        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 @@ pop3_header_filter_callback(struct header_filter_istream *input ATTR_UNUSED,
                }
                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;
+               }
        }
 }