]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: Fix deduplication of alias_for namespaces
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 26 Aug 2024 08:52:36 +0000 (11:52 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 17 Jan 2025 08:40:00 +0000 (10:40 +0200)
The pointer checks didn't actually work, because they weren't set at this
point yet.

src/plugins/quota/quota.c

index 0702f5769896240b98cd072cb6fb5aa5c4c43ebb..57f69c5f578eafc7574bcbd2d77fb7d6e4e21fe6 100644 (file)
@@ -495,12 +495,14 @@ quota_is_duplicate_namespace(struct quota *quota, struct mail_namespace *ns)
 
        namespaces = array_get(&quota->namespaces, &count);
        for (i = 0; i < count; i++) {
-               /* count namespace aliases only once. don't rely only on
-                  alias_for != NULL, because the alias might have been
-                  explicitly added as the wanted quota namespace. */
-               if (ns->alias_for == namespaces[i] ||
-                   namespaces[i]->alias_for == ns)
-                       continue;
+               /* Count namespace aliases only once. Don't rely only on
+                  non-empty alias_for, because the alias might have been
+                  explicitly added as the wanted quota namespace. We can't
+                  use ns->alias_for pointer comparisons directly, because they
+                  are set later. */
+               if (strcmp(ns->set->alias_for, namespaces[i]->set->name) == 0 ||
+                   strcmp(namespaces[i]->set->alias_for, ns->set->name) == 0)
+                       return TRUE;
 
                if (path != NULL &&
                    mailbox_list_get_root_path(namespaces[i]->list,