]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Don't crash listing subscription entry of "ns prefix" without separator.
authorTimo Sirainen <tss@iki.fi>
Wed, 3 Aug 2011 17:44:43 +0000 (20:44 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 3 Aug 2011 17:44:43 +0000 (20:44 +0300)
src/lib-storage/list/mailbox-list-subscriptions.c

index b186e97e4cac747ea2c711576f0b7b32e4694a11..77e22d2a35774195eb7f9b17eb3f727cd646b398 100644 (file)
@@ -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);