Mercurial > dovecot > core-2.2
changeset 22193:33222df76027
lib-storage: Fail mailbox list iteration early if it fails to get INBOX flags
The resulting INBOX reply could be wrong in that case.
Also with imapc if the remote server is down, this causes two connection
errors instead of just one.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Mon, 12 Jun 2017 14:33:46 +0300 |
parents | d1f41384291a |
children | 129d80313246 |
files | src/lib-storage/list/mailbox-list-iter.c |
diffstat | 1 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/list/mailbox-list-iter.c Mon Jun 12 14:16:13 2017 +0300 +++ b/src/lib-storage/list/mailbox-list-iter.c Mon Jun 12 14:33:46 2017 +0300 @@ -707,17 +707,19 @@ return imap_match(glob, "INBOX") == IMAP_MATCH_YES; } -static void inbox_info_init(struct ns_list_iterate_context *ctx, - struct mail_namespace *namespaces) +static int inbox_info_init(struct ns_list_iterate_context *ctx, + struct mail_namespace *namespaces) { enum mailbox_info_flags flags; + int ret; ctx->inbox_info.vname = "INBOX"; ctx->inbox_info.ns = mail_namespace_find_inbox(namespaces); i_assert(ctx->inbox_info.ns != NULL); - if (mailbox_list_mailbox(ctx->inbox_info.ns->list, "INBOX", &flags) > 0) + if ((ret = mailbox_list_mailbox(ctx->inbox_info.ns->list, "INBOX", &flags)) > 0) ctx->inbox_info.flags = flags; + return ret; } struct mailbox_list_iterate_context * @@ -754,7 +756,10 @@ else called INBOX (e.g. namespace prefix) we can show it immediately with the proper flags. */ ctx->inbox_list = TRUE; - inbox_info_init(ctx, namespaces); + if (inbox_info_init(ctx, namespaces) < 0) { + pool_unref(&pool); + return &mailbox_list_iter_failed; + } } if ((flags & MAILBOX_LIST_ITER_STAR_WITHIN_NS) != 0) {