From: Aki Tuomi Date: Thu, 22 Oct 2020 17:21:41 +0000 (+0300) Subject: quota: Avoid implicit integer conversion to unsigned in quota calculation X-Git-Tag: 2.3.13~66 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7a97dfb74f5f2bda6531c6e3584767edce26433f;p=thirdparty%2Fdovecot%2Fcore.git quota: Avoid implicit integer conversion to unsigned in quota calculation Deducting negative number from unsigned integer causes signed integer conversion to unsigned int, which results a too large positive number. Do calculations using int64 instead. This did not cause any visible problems, found by clang integer sanitization. --- diff --git a/src/plugins/quota/quota.c b/src/plugins/quota/quota.c index 1457ffe654..ef58e71838 100644 --- a/src/plugins/quota/quota.c +++ b/src/plugins/quota/quota.c @@ -1121,12 +1121,12 @@ static void quota_warnings_execute(struct quota_transaction_context *ctx, if (ctx->bytes_used > 0 && bytes_current < (uint64_t)ctx->bytes_used) bytes_before = 0; else - bytes_before = bytes_current - ctx->bytes_used; + bytes_before = (int64_t)bytes_current - ctx->bytes_used; if (ctx->count_used > 0 && count_current < (uint64_t)ctx->count_used) count_before = 0; else - count_before = count_current - ctx->count_used; + count_before = (int64_t)count_current - ctx->count_used; for (i = 0; i < count; i++) { if (quota_warning_match(&warnings[i], bytes_before, bytes_current,