From: Stephan Bosch Date: Fri, 16 Nov 2018 15:26:22 +0000 (+0100) Subject: trash: Do not modify *_ceil and *_over fields in struct quota_transaction_context X-Git-Tag: 2.4.1~135 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=08fdf481dd78e39b9ba3b07cf74cd31bd2d8d36b;p=thirdparty%2Fdovecot%2Fcore.git trash: Do not modify *_ceil and *_over fields in struct quota_transaction_context These are not supposed to be modified. Instead, increase the *_expunged fields. --- diff --git a/src/plugins/trash/trash-plugin.c b/src/plugins/trash/trash-plugin.c index 8681238c0f..0c496b241e 100644 --- a/src/plugins/trash/trash-plugin.c +++ b/src/plugins/trash/trash-plugin.c @@ -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; }