changeset 6535:d4d6457550b5 HEAD

Don't break when renaming mailboxes with '*' or '%' characters and children.
author Timo Sirainen <tss@iki.fi>
date Sat, 06 Oct 2007 03:05:37 +0300
parents dea6ed0002ae
children 2a2fd5c3b42e
files src/lib-storage/list/mailbox-list-maildir.c
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/list/mailbox-list-maildir.c	Sat Oct 06 02:48:07 2007 +0300
+++ b/src/lib-storage/list/mailbox-list-maildir.c	Sat Oct 06 03:05:37 2007 +0300
@@ -322,10 +322,14 @@
 	while ((info = mailbox_list_iter_next(iter)) != NULL) {
 		const char *name;
 
-		i_assert(oldnamelen <= strlen(info->name));
-
-		name = p_strdup(pool, info->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(info->name, oldname, oldnamelen) == 0 &&
+		    info->name[oldnamelen] ==
+		    mailbox_list_get_hierarchy_sep(list)) {
+			name = p_strdup(pool, info->name + oldnamelen);
+			array_append(&names_arr, &name, 1);
+		}
 	}
 	if (mailbox_list_iter_deinit(&iter) < 0) {
 		ret = -1;