]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: Quota count tracking still was still incorrect in over-quota conditions.
authorTimo Sirainen <tss@iki.fi>
Thu, 3 Jul 2014 08:37:07 +0000 (11:37 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 3 Jul 2014 08:37:07 +0000 (11:37 +0300)
src/plugins/quota/quota-util.c
src/plugins/quota/test-quota-util.c

index 31ca18582dedf7bdb76c0c734a346734f2cf8419..6735f0b70f0b5bec74a16f796ea68558e7647029 100644 (file)
@@ -395,11 +395,11 @@ bool quota_transaction_is_over(struct quota_transaction_context *ctx,
                /* we've deleted some messages. we should be ok, unless we
                   were already over quota and still are after these
                   deletions. */
+               const uint64_t count_deleted = (uint64_t)-ctx->count_used;
+
                if (ctx->count_over > 0) {
-                       if (ctx->count_over > (uint64_t)-ctx->count_used + 1)
+                       if (count_deleted - 1 < ctx->count_over)
                                return TRUE;
-               } else {
-                       return TRUE;
                }
        } else {
                if (ctx->count_ceil < 1 ||
index 66d306bfbdef041f8d324643d1d70d0f678fe6e2..83b0ebc119eaf1f195463ad74c240a3d3c7e7ffb 100644 (file)
@@ -25,6 +25,10 @@ static void test_quota_transaction_is_over(void)
                { MAXU64,   MAXU64,        0,   1, TRUE },
                { MAXU64, MAXU64-1,        0,   1, FALSE },
                { MAXU64, MAXU64-1,        1,   1, TRUE },
+               { MAXU64-1, MAXU64-1,      0,   1, TRUE },
+               { MAXU64-1, MAXU64-1,     -1,   1, FALSE },
+               { MAXU64-2, MAXU64-1,     -1,   1, TRUE },
+               { MAXU64-2, MAXU64-1,     -2,   1, FALSE },
 
                /* these are for bytes tests: */