From: Timo Sirainen Date: Wed, 3 Aug 2011 17:44:43 +0000 (+0300) Subject: lib-storage: Don't crash listing subscription entry of "ns prefix" without separator. X-Git-Tag: 2.1.alpha1~190 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7bdea8f7a7c87ba1974bb7a2e69a6b3d62bbdea;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Don't crash listing subscription entry of "ns prefix" without separator. --- diff --git a/src/lib-storage/list/mailbox-list-subscriptions.c b/src/lib-storage/list/mailbox-list-subscriptions.c index b186e97e4c..77e22d2a35 100644 --- a/src/lib-storage/list/mailbox-list-subscriptions.c +++ b/src/lib-storage/list/mailbox-list-subscriptions.c @@ -61,11 +61,16 @@ mailbox_list_subscription_fill_one(struct mailbox_list *list, /* When listing pub/ namespace, skip over the namespace prefix in the name. the rest of the name is storage_name. */ - if (ns != NULL) { - i_assert(strncmp(name, ns->prefix, ns->prefix_len) == 0); - name += ns->prefix_len; - } else { + if (ns == NULL) ns = default_ns; + else if (strncmp(name, ns->prefix, ns->prefix_len) == 0) + name += ns->prefix_len; + else { + /* "pub" entry - this shouldn't be possible normally, because + it should be saved as "pub/", but handle it anyway */ + i_assert(strncmp(name, ns->prefix, ns->prefix_len-1) == 0 && + name[ns->prefix_len-1] == '\0'); + name = ""; } len = strlen(name);