]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: quota-util - Assert that either ceil or over parameter equals 0 in quota_is_over()
authorStephan Bosch <stephan.bosch@open-xchange.com>
Tue, 9 Nov 2021 22:33:42 +0000 (23:33 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 26 Feb 2025 10:45:00 +0000 (10:45 +0000)
src/plugins/quota/quota-util.c

index 3e83b665048e2fc78b10fa450fa72ec4be70ca05..3ea95d7b49186303e96e38234d891603c5a14bb9 100644 (file)
@@ -57,6 +57,13 @@ int quota_get_mail_size(struct quota_transaction_context *ctx,
 static inline bool
 quota_is_over(uoff_t alloc, int64_t used, uint64_t ceil, uint64_t over)
 {
+       /* The over parameter is the amount by which the resource usage exceeds
+          the limit already. The ceil parameter is the amount by which the
+          resource usage is allowed to increase before crossing the limit.
+          Therefore, the over and ceil values are mutually exclusive; these
+          cannot both be nonzero. */
+       i_assert(over == 0 || ceil == 0);
+
        if (used < 0) {
                /* Resource usage decreased in this transaction. */
                const uint64_t deleted = (uint64_t)-used;