]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap-quota: Don't crash if invalid mailbox name is given to GETQUOTAROOT.
authorTimo Sirainen <tss@iki.fi>
Wed, 27 Jul 2011 16:46:01 +0000 (19:46 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 27 Jul 2011 16:46:01 +0000 (19:46 +0300)
src/plugins/imap-quota/imap-quota-plugin.c

index 5ac7cef7cdb2836ce5abb3a1a33ab5ff17eab883..738af632fec13549a0441fc7c93b79013a34ed88 100644 (file)
@@ -74,6 +74,7 @@ static bool cmd_getquotaroot(struct client_command_context *cmd)
        struct mailbox *box;
        struct quota_root_iter *iter;
         struct quota_root *root;
+       enum mailbox_name_status status;
        const char *mailbox, *storage_name, *name;
        string_t *quotaroot_reply, *quota_reply;
 
@@ -81,7 +82,7 @@ static bool cmd_getquotaroot(struct client_command_context *cmd)
        if (!client_read_string_args(cmd, 1, &mailbox))
                return FALSE;
 
-       ns = client_find_namespace(cmd, mailbox, &storage_name, NULL);
+       ns = client_find_namespace(cmd, mailbox, &storage_name, &status);
        if (ns == NULL)
                return TRUE;
 
@@ -94,6 +95,10 @@ static bool cmd_getquotaroot(struct client_command_context *cmd)
                client_send_tagline(cmd, "NO Not showing other users' quota.");
                return TRUE;
        }
+       if (status == MAILBOX_NAME_INVALID) {
+               client_fail_mailbox_name_status(cmd, mailbox, NULL, status);
+               return TRUE;
+       }
 
        box = mailbox_alloc(ns->list, storage_name, MAILBOX_FLAG_READONLY |
                            MAILBOX_FLAG_KEEP_RECENT);