[Dovecot] potential maildir folder rename bug
pod
pod at herald.ox.ac.uk
Mon Oct 1 22:21:13 EEST 2007
Admittedly not a common situation but:
MAIL=maildir:~/tmp/dovecot/Maildir ./src/imap/imap
* PREAUTH [CAPABILITY IMAP4rev1 SASL-IR SORT THREAD=REFERENCES MULTIAPPEND UNSELECT LITERAL+ IDLE CHILDREN NAMESPACE LOGIN-REFERRALS] Logged in as pod
01 LIST "" *
* LIST (\HasNoChildren) "." "INBOX"
01 OK List completed.
02 CREATE a
02 OK Create completed.
03 LIST "" *
* LIST (\HasNoChildren) "." "a"
* LIST (\HasNoChildren) "." "INBOX"
03 OK List completed.
04 RENAME a a.b
04 OK Rename completed.
05 LIST "" *
* LIST (\HasNoChildren) "." "a.b.b"
* LIST (\HasNoChildren) "." "INBOX"
05 OK List completed.
I was expecting to wind up with two folders "INBOX" and "a.b". Instead I
got "INBOX" and "a.b.b".
I think the problem is that ".a" gets renamed in the filesystem to ".a.b"
before src/lib-storage/index/maildir/maildir-storage.c rename_subfolders()
is called, which then finds ".a.b", assumes "b" was a subfolder of "a" so
renames it.
The following may or may not be an appropriate fix. It certainly feels
rather ad hoc and I've not thought too deeply about other circumstances
where this code is called. I'd certainly appreciate a second opinion.
diff -r 8d6433652a33 src/lib-storage/index/maildir/maildir-storage.c
--- a/src/lib-storage/index/maildir/maildir-storage.c Sun Sep 30 18:03:17 2007 +0300
+++ b/src/lib-storage/index/maildir/maildir-storage.c Mon Oct 01 20:13:27 2007 +0100
@@ -937,6 +937,10 @@ static int rename_subfolders(struct inde
t_push();
old_listname = t_strconcat(oldname, names[i], NULL);
+ if (strcmp(old_listname, newname) == 0) {
+ t_pop();
+ continue;
+ }
new_listname = t_strconcat(newname, names[i], NULL);
oldpath = maildir_get_path(storage, old_listname);
newpath = maildir_get_path(storage, new_listname);
More information about the dovecot
mailing list