]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dict quota: Avoid crashing if quota recalculation tries to recurse.
authorTimo Sirainen <tss@iki.fi>
Tue, 21 Sep 2010 17:15:56 +0000 (18:15 +0100)
committerTimo Sirainen <tss@iki.fi>
Tue, 21 Sep 2010 17:15:56 +0000 (18:15 +0100)
src/plugins/quota/quota-count.c
src/plugins/quota/quota-private.h

index f80582d117247f883d377bee69b3e5d7cd5f0a8d..6a11e3ccc24de39ce3194a979b3261cdc39d109b 100644 (file)
@@ -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;
 }
index f0f16cf81a39510a74886b8b9a5a3aee42ac4a37..0018de3a487596bf8def60a5c0fcd99b53cc996e 100644 (file)
@@ -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 {