dovecot: Don't crash when listing mailboxes in a namespace with ...

dovecot at dovecot.org dovecot at dovecot.org
Sun Oct 21 20:36:38 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/1478fc5cf632
changeset: 6604:1478fc5cf632
user:      Timo Sirainen <tss at iki.fi>
date:      Sun Oct 21 20:36:35 2007 +0300
description:
Don't crash when listing mailboxes in a namespace with a prefix.

diffstat:

1 file changed, 12 insertions(+), 1 deletion(-)
src/plugins/acl/acl-mailbox-list.c |   13 ++++++++++++-

diffs (31 lines):

diff -r afc28dd2d4c5 -r 1478fc5cf632 src/plugins/acl/acl-mailbox-list.c
--- a/src/plugins/acl/acl-mailbox-list.c	Sun Oct 21 19:59:09 2007 +0300
+++ b/src/plugins/acl/acl-mailbox-list.c	Sun Oct 21 20:36:35 2007 +0300
@@ -161,7 +161,12 @@ acl_mailbox_list_iter_next(struct mailbo
 	struct acl_mailbox_list *alist = ACL_LIST_CONTEXT(_ctx->list);
 	const struct mailbox_info *info;
 	struct mailbox_node *node;
+	const char *ns_prefix, *acl_name;
+	unsigned int ns_prefix_len;
 	int ret;
+
+	ns_prefix = _ctx->list->ns->prefix;
+	ns_prefix_len = strlen(ns_prefix);
 
 	for (;;) {
 		if (ctx->tree_iter != NULL) {
@@ -183,7 +188,13 @@ acl_mailbox_list_iter_next(struct mailbo
 			return info;
 		}
 
-		ret = acl_mailbox_list_have_right(alist, info->name,
+		/* Mailbox names contain namespace prefix, except when listing
+		   INBOX. */
+		acl_name = info->name;
+		if (strncmp(acl_name, ns_prefix, ns_prefix_len) == 0)
+			acl_name += ns_prefix_len;
+
+		ret = acl_mailbox_list_have_right(alist, acl_name,
 						  ACL_STORAGE_RIGHT_LOOKUP,
 						  NULL);
 		if (ret > 0)


More information about the dovecot-cvs mailing list