Mercurial > dovecot > original-hg > dovecot-1.2
changeset 7141:ead08ca27435 HEAD
Disallow RENAME box box/child.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 10 Jan 2008 05:11:09 +0200 |
parents | 979294cabcab |
children | 58cb2c6f90c7 |
files | src/imap/cmd-rename.c |
diffstat | 1 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/imap/cmd-rename.c Thu Jan 10 04:41:38 2008 +0200 +++ b/src/imap/cmd-rename.c Thu Jan 10 05:11:09 2008 +0200 @@ -1,13 +1,16 @@ /* Copyright (c) 2002-2008 Dovecot authors, see the included COPYING file */ #include "common.h" +#include "mail-namespace.h" #include "commands.h" bool cmd_rename(struct client_command_context *cmd) { struct mail_storage *old_storage, *new_storage; struct mailbox_list *list; + struct mail_namespace *ns; const char *oldname, *newname; + unsigned int oldlen; /* <old name> <new name> */ if (!client_read_string_args(cmd, 2, &oldname, &newname)) @@ -30,7 +33,18 @@ return TRUE; } + /* disallow box -> box/child, because it may break clients and there's + really no point in doing it anyway. */ list = mail_storage_get_list(old_storage); + ns = mailbox_list_get_namespace(list); + oldlen = strlen(oldname); + if (strncmp(oldname, newname, oldlen) == 0 && + newname[oldlen] == ns->real_sep) { + client_send_tagline(cmd, + "NO Can't rename mailbox under its own child."); + return TRUE; + } + if (mailbox_list_rename_mailbox(list, oldname, newname) < 0) client_send_list_error(cmd, list); else {