From 5ec5c0d15cbd46cf035f17b523fb6b09c62d75a9 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Mon, 26 Aug 2024 11:52:36 +0300 Subject: [PATCH] quota: Fix deduplication of alias_for namespaces The pointer checks didn't actually work, because they weren't set at this point yet. --- src/plugins/quota/quota.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/plugins/quota/quota.c b/src/plugins/quota/quota.c index 0702f57698..57f69c5f57 100644 --- a/src/plugins/quota/quota.c +++ b/src/plugins/quota/quota.c @@ -495,12 +495,14 @@ quota_is_duplicate_namespace(struct quota *quota, struct mail_namespace *ns) namespaces = array_get("a->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, -- 2.47.3