dovecot-2.0: dict quota: Avoid crashing if quota recalculation t...

dovecot at dovecot.org dovecot at dovecot.org
Tue Sep 21 20:16:00 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/ee91aee81d0d
changeset: 12151:ee91aee81d0d
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Sep 21 18:15:56 2010 +0100
description:
dict quota: Avoid crashing if quota recalculation tries to recurse.

diffstat:

 src/plugins/quota/quota-count.c   |  4 ++++
 src/plugins/quota/quota-private.h |  2 ++
 2 files changed, 6 insertions(+), 0 deletions(-)

diffs (32 lines):

diff -r 3780caa2a6f2 -r ee91aee81d0d src/plugins/quota/quota-count.c
--- a/src/plugins/quota/quota-count.c	Tue Sep 21 18:05:13 2010 +0100
+++ b/src/plugins/quota/quota-count.c	Tue Sep 21 18:15:56 2010 +0100
@@ -99,6 +99,9 @@
 	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 @@
 		if (ret < 0)
 			break;
 	}
+	root->recounting = FALSE;
 	return ret;
 }
diff -r 3780caa2a6f2 -r ee91aee81d0d src/plugins/quota/quota-private.h
--- a/src/plugins/quota/quota-private.h	Tue Sep 21 18:05:13 2010 +0100
+++ b/src/plugins/quota/quota-private.h	Tue Sep 21 18:15:56 2010 +0100
@@ -119,6 +119,8 @@
 	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 {


More information about the dovecot-cvs mailing list