From: Timo Sirainen Date: Sun, 11 Jul 2010 18:19:45 +0000 (+0100) Subject: acl: Fixed crashing on FS layout with non-default hierarchy separator. X-Git-Tag: 2.0.rc3~87 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0a167fd961775cb203f862a3a6bc5e55ce8e76c9;p=thirdparty%2Fdovecot%2Fcore.git acl: Fixed crashing on FS layout with non-default hierarchy separator. --- diff --git a/src/plugins/acl/acl-mailbox-list.c b/src/plugins/acl/acl-mailbox-list.c index 4b199e3c30..085bd77879 100644 --- a/src/plugins/acl/acl-mailbox-list.c +++ b/src/plugins/acl/acl-mailbox-list.c @@ -288,7 +288,8 @@ iter_mailbox_has_visible_children(struct acl_mailbox_list_iterate_context *ctx, str_append_c(pattern, '%'); } } - str_append_c(pattern, ctx->sep); + if (i > 0 && ctx->info.name[i-1] != ctx->sep) + str_append_c(pattern, ctx->sep); str_append_c(pattern, '*'); prefix = str_c(pattern); prefix_len = str_len(pattern) - 1; @@ -329,8 +330,12 @@ acl_mailbox_list_info_is_visible(struct acl_mailbox_list_iterate_context *ctx) ACL_STORAGE_RIGHT_LOOKUP, NULL); if (ret != 0) { - if ((info->flags & MAILBOX_CHILDREN) != 0 && - !iter_mailbox_has_visible_children(ctx, FALSE)) { + if ((ctx->ctx.flags & MAILBOX_LIST_ITER_RETURN_NO_FLAGS) != 0) { + /* don't waste time checking if there are visible + children, but also don't return incorrect flags */ + info->flags &= ~MAILBOX_CHILDREN; + } else if ((info->flags & MAILBOX_CHILDREN) != 0 && + !iter_mailbox_has_visible_children(ctx, FALSE)) { info->flags &= ~MAILBOX_CHILDREN; info->flags |= MAILBOX_NOCHILDREN; }