]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
trash: Do not modify *_ceil and *_over fields in struct quota_transaction_context
authorStephan Bosch <stephan.bosch@dovecot.fi>
Fri, 16 Nov 2018 15:26:22 +0000 (16:26 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 26 Feb 2025 10:45:00 +0000 (10:45 +0000)
These are not supposed to be modified. Instead, increase the *_expunged fields.

src/plugins/trash/trash-plugin.c

index 8681238c0fe6aa7890bf54c3f7bbabf017de3db3..0c496b241e3fd85986db69421c21c0bac086e5b3 100644 (file)
@@ -322,29 +322,16 @@ trash_clean_execute(struct trash_clean *tclean,
                return ret;
 
        /* Update the resource usage state */
-       if (ctx->bytes_over > 0) {
-               /* user is over quota. drop the over-bytes first. */
-               i_assert(ctx->bytes_over <= tclean->bytes_expunged);
-               tclean->bytes_expunged -= ctx->bytes_over;
-               ctx->bytes_over = 0;
-       }
-       if (ctx->count_over > 0) {
-               /* user is over quota. drop the over-count first. */
-               i_assert(ctx->count_over <= tclean->count_expunged);
-               tclean->count_expunged -= ctx->count_over;
-               ctx->count_over = 0;
-       }
+       if ((UINT64_MAX - tclean->count_expunged) < ctx->count_expunged)
+               ctx->count_expunged = UINT64_MAX;
+       else
+               ctx->count_expunged += tclean->count_expunged;
+
+       if ((UINT64_MAX - tclean->bytes_expunged) < ctx->bytes_expunged)
+               ctx->bytes_expunged = UINT64_MAX;
+       else
+               ctx->bytes_expunged += tclean->bytes_expunged;
 
-       if (ctx->bytes_ceil > (UINT64_MAX - tclean->bytes_expunged)) {
-               ctx->bytes_ceil = UINT64_MAX;
-       } else {
-               ctx->bytes_ceil += tclean->bytes_expunged;
-       }
-       if (ctx->count_ceil < (UINT64_MAX - tclean->count_expunged)) {
-               ctx->count_ceil = UINT64_MAX;
-       } else {
-               ctx->count_ceil += tclean->count_expunged;
-       }
        return 1;
 }