From: Timo Sirainen Date: Tue, 21 Sep 2010 17:15:56 +0000 (+0100) Subject: dict quota: Avoid crashing if quota recalculation tries to recurse. X-Git-Tag: 2.0.4~30 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8eb223b84389a7b75a39d46484f5166d221305eb;p=thirdparty%2Fdovecot%2Fcore.git dict quota: Avoid crashing if quota recalculation tries to recurse. --- diff --git a/src/plugins/quota/quota-count.c b/src/plugins/quota/quota-count.c index f80582d117..6a11e3ccc2 100644 --- a/src/plugins/quota/quota-count.c +++ b/src/plugins/quota/quota-count.c @@ -99,6 +99,9 @@ int quota_count(struct quota_root *root, uint64_t *bytes_r, uint64_t *count_r) int ret = 0; *bytes_r = *count_r = 0; + if (root->recounting) + return 0; + root->recounting = TRUE; namespaces = array_get(&root->quota->namespaces, &count); for (i = 0; i < count; i++) { @@ -110,5 +113,6 @@ int quota_count(struct quota_root *root, uint64_t *bytes_r, uint64_t *count_r) if (ret < 0) break; } + root->recounting = FALSE; return ret; } diff --git a/src/plugins/quota/quota-private.h b/src/plugins/quota/quota-private.h index f0f16cf81a..0018de3a48 100644 --- a/src/plugins/quota/quota-private.h +++ b/src/plugins/quota/quota-private.h @@ -119,6 +119,8 @@ struct quota_root { unsigned int no_enforcing:1; /* If user has unlimited quota, disable quota tracking */ unsigned int disable_unlimited_tracking:1; + /* Set while quota is being recalculated to avoid recursion. */ + unsigned int recounting:1; }; struct quota_transaction_context {