Mercurial > dovecot > core-2.2
changeset 12954:4fe53879ceb1
maildir: Remove invalid extension records from dovecot-uidlist.
For now we'll assume that if the key is outside A..Z it's invalid. Since
only 4 keys are used currently, there is still a lot of letters available
for future use.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 20 Apr 2011 17:57:20 +0300 |
parents | d3d635ee3016 |
children | fa2e92526716 |
files | src/lib-storage/index/maildir/maildir-uidlist.c src/lib-storage/index/maildir/maildir-uidlist.h |
diffstat | 2 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/maildir/maildir-uidlist.c Wed Apr 20 17:44:36 2011 +0300 +++ b/src/lib-storage/index/maildir/maildir-uidlist.c Wed Apr 20 17:57:20 2011 +0300 @@ -423,8 +423,15 @@ /* skip over an extension field */ start = line; while (*line != ' ' && *line != '\0') line++; - buffer_append(buf, start, line - start); - buffer_append_c(buf, '\0'); + if (MAILDIR_UIDLIST_REC_EXT_KEY_IS_VALID(*start)) { + buffer_append(buf, start, line - start); + buffer_append_c(buf, '\0'); + } else { + maildir_uidlist_set_corrupted(uidlist, + "Invalid extension record, removing: %s", + t_strdup_until(start, line)); + uidlist->recreate = TRUE; + } while (*line == ' ') line++; }
--- a/src/lib-storage/index/maildir/maildir-uidlist.h Wed Apr 20 17:44:36 2011 +0300 +++ b/src/lib-storage/index/maildir/maildir-uidlist.h Wed Apr 20 17:57:20 2011 +0300 @@ -37,6 +37,8 @@ MAILDIR_UIDLIST_HDR_EXT_POP3_UIDL_FORMAT = 'P' }; +#define MAILDIR_UIDLIST_REC_EXT_KEY_IS_VALID(c) \ + ((c) >= 'A' && (c) <= 'Z') enum maildir_uidlist_rec_ext_key { /* Physical message size. If filename also contains ,S=<vsize> this isn't written to uidlist. */