From d1f799aa12b82c09689b09767852b9b9c4d89db9 Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Fri, 7 Dec 2018 09:14:25 +0200 Subject: [PATCH] quota: Do not set limits to infinity when not enforcing Fixes quota enforcement to work even if secondary quota is noenforcing. --- src/plugins/quota/quota.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/plugins/quota/quota.c b/src/plugins/quota/quota.c index 6db5b63070..2895904e89 100644 --- a/src/plugins/quota/quota.c +++ b/src/plugins/quota/quota.c @@ -938,12 +938,12 @@ int quota_transaction_set_limits(struct quota_transaction_context *ctx, /* find the lowest quota limits from all roots and use them */ roots = array_get(&ctx->quota->roots, &count); for (i = 0; i < count; i++) { + /* make sure variables get initialized */ + bytes_limit = count_limit = 0; if (!quota_root_is_visible(roots[i], ctx->box) || (roots[i]->no_enforcing && ctx->auto_updating)) continue; else if (roots[i]->no_enforcing) { - bytes_limit = (uint64_t)-1; - count_limit = (uint64_t)-1; ignored = FALSE; } else if (quota_root_get_rule_limits(roots[i], mailbox_name, &bytes_limit, &count_limit, @@ -962,10 +962,7 @@ int quota_transaction_set_limits(struct quota_transaction_context *ctx, ret = quota_get_resource(roots[i], mailbox_name, QUOTA_NAME_STORAGE_BYTES, ¤t, &limit, &error); - if (roots[i]->no_enforcing) { - ctx->bytes_ceil = (uint64_t)-1; - ctx->bytes_ceil2 = (uint64_t)-1; - } else if (ret == QUOTA_GET_RESULT_LIMITED) { + if (ret == QUOTA_GET_RESULT_LIMITED) { if (limit <= current) { /* over quota */ ctx->bytes_ceil = 0; @@ -997,9 +994,7 @@ int quota_transaction_set_limits(struct quota_transaction_context *ctx, ret = quota_get_resource(roots[i], mailbox_name, QUOTA_NAME_MESSAGES, ¤t, &limit, &error); - if (roots[i]->no_enforcing) { - ctx->count_ceil = (uint64_t)-1; - } else if (ret == QUOTA_GET_RESULT_LIMITED) { + if (ret == QUOTA_GET_RESULT_LIMITED) { if (limit <= current) { /* over quota */ ctx->count_ceil = 0; -- 2.47.3