]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Fail if no namespaces have list=yes
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 24 Nov 2016 17:53:17 +0000 (19:53 +0200)
committerGitLab <gitlab@git.dovecot.net>
Fri, 25 Nov 2016 10:12:12 +0000 (12:12 +0200)
The previous check allowed all namespaces to have list=children. This
crashed later on in mail_namespaces_get_root_sep(), because it couldn't
find any list=yes namespaces.

src/lib-storage/mail-namespace.c

index 46b2397dc62a07ce3a20e72ac1745783a2f7fd6b..1eea385ddab2f6565277b095427275d1bd2370ed 100644 (file)
@@ -263,7 +263,7 @@ namespaces_check(struct mail_namespace *namespaces, const char **error_r)
 {
        struct mail_namespace *ns, *inbox_ns = NULL;
        unsigned int subscriptions_count = 0;
-       bool visible_namespaces = FALSE;
+       bool visible_namespaces = FALSE, have_list_yes = FALSE;
        char ns_sep, list_sep = '\0';
 
        for (ns = namespaces; ns != NULL; ns = ns->next) {
@@ -308,6 +308,8 @@ namespaces_check(struct mail_namespace *namespaces, const char **error_r)
                }
                if ((ns->flags & (NAMESPACE_FLAG_LIST_PREFIX |
                                  NAMESPACE_FLAG_LIST_CHILDREN)) != 0) {
+                       if ((ns->flags & NAMESPACE_FLAG_LIST_PREFIX) != 0)
+                               have_list_yes = TRUE;
                        if (list_sep == '\0')
                                list_sep = ns_sep;
                        else if (list_sep != ns_sep) {
@@ -324,7 +326,7 @@ namespaces_check(struct mail_namespace *namespaces, const char **error_r)
                *error_r = "inbox=yes namespace missing";
                return FALSE;
        }
-       if (list_sep == '\0') {
+       if (!have_list_yes) {
                *error_r = "list=yes namespace missing";
                return FALSE;
        }