]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imapc: If root separator lookup fails, fail all further lookups.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 6 Apr 2016 11:44:00 +0000 (14:44 +0300)
committerGitLab <gitlab@git.dovecot.net>
Tue, 12 Apr 2016 13:06:48 +0000 (16:06 +0300)
We already returned a potentially wrong separator (since there's no way to
return error), so we don't want to continue and possibly make things worse.

src/lib-storage/index/imapc/imapc-list.c
src/lib-storage/index/imapc/imapc-list.h

index 4c25f157c497cb0360c065380b294cc77c600b5a..72827814bc0fed81a5e416e8954e5e9e36b8c95d 100644 (file)
@@ -324,9 +324,11 @@ static char imapc_list_get_hierarchy_sep(struct mailbox_list *_list)
        struct imapc_mailbox_list *list = (struct imapc_mailbox_list *)_list;
        char sep;
 
-       if (imapc_list_try_get_root_sep(list, &sep) < 0) {
-               /* we can't really fail here. just return a common separator
-                  and keep failing all list commands until it succeeds. */
+       if (list->root_sep_lookup_failed ||
+           imapc_list_try_get_root_sep(list, &sep) < 0) {
+               /* we can't really return a failure here. just return a common
+                  separator and fail all the future list operations. */
+               list->root_sep_lookup_failed = TRUE;
                return '/';
        }
        return sep;
@@ -546,6 +548,10 @@ static int imapc_list_refresh(struct imapc_mailbox_list *list)
        struct mailbox_node *node;
        const char *pattern;
 
+       if (list->root_sep_lookup_failed) {
+               mailbox_list_set_internal_error(&list->list);
+               return -1;
+       }
        if (list->refreshed_mailboxes)
                return 0;
 
@@ -774,6 +780,11 @@ imapc_list_subscriptions_refresh(struct mailbox_list *_src_list,
 
        i_assert(src_list->tmp_subscriptions == NULL);
 
+       if (src_list->root_sep_lookup_failed) {
+               mailbox_list_set_internal_error(_src_list);
+               return -1;
+       }
+
        if (src_list->refreshed_subscriptions) {
                if (dest_list->subscriptions == NULL)
                        dest_list->subscriptions = mailbox_tree_init(dest_sep);
index 9991442557f7aec946dcab103eef98d4bbf6a365..8e4eee6da7b5bac475a3c47f64011ec551142ca5 100644 (file)
@@ -30,6 +30,7 @@ struct imapc_mailbox_list {
        unsigned int refreshed_mailboxes_recently:1;
        unsigned int index_list_failed:1;
        unsigned int root_sep_pending:1;
+       unsigned int root_sep_lookup_failed:1;
 };
 
 int imapc_list_get_mailbox_flags(struct mailbox_list *list, const char *name,