dovecot-1.0: Don't break when renaming mailboxes with '*' or '%'...

dovecot at dovecot.org dovecot at dovecot.org
Sat Oct 6 03:05:40 EEST 2007


details:   http://hg.dovecot.org/dovecot-1.0/rev/880d21a2a629
changeset: 5422:880d21a2a629
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Oct 06 03:05:36 2007 +0300
description:
Don't break when renaming mailboxes with '*' or '%' characters and children.

diffstat:

1 file changed, 7 insertions(+), 4 deletions(-)
src/lib-storage/index/maildir/maildir-storage.c |   11 +++++++----

diffs (21 lines):

diff -r 191b1cde3260 -r 880d21a2a629 src/lib-storage/index/maildir/maildir-storage.c
--- a/src/lib-storage/index/maildir/maildir-storage.c	Mon Oct 01 18:14:43 2007 +0300
+++ b/src/lib-storage/index/maildir/maildir-storage.c	Sat Oct 06 03:05:36 2007 +0300
@@ -921,10 +921,13 @@ static int rename_subfolders(struct inde
 	while ((list = maildir_mailbox_list_next(ctx)) != NULL) {
 		const char *name;
 
-		i_assert(oldnamelen <= strlen(list->name));
-
-		name = p_strdup(pool, list->name + oldnamelen);
-		array_append(&names_arr, &name, 1);
+		/* verify that the prefix matches, otherwise we could have
+		   problems with mailbox names containing '%' and '*' chars */
+		if (strncmp(list->name, oldname, oldnamelen) == 0 &&
+		    list->name[oldnamelen] == MAILDIR_FS_SEP) {
+			name = p_strdup(pool, list->name + oldnamelen);
+			array_append(&names_arr, &name, 1);
+		}
 	}
 	if (maildir_mailbox_list_deinit(ctx) < 0) {
 		ret = -1;


More information about the dovecot-cvs mailing list