# HG changeset patch # User Timo Sirainen # Date 1486492901 -7200 # Node ID 6c88e7e55768f075d2e2db206b03ce8ee1febc20 # Parent ee051f0429b2733d3d5a1bb6cba1974181be718f quota: Make sure quota_warning doesn't wrap "quota before" value. This could happen in some race conditions (and with bugs). diff -r ee051f0429b2 -r 6c88e7e55768 src/plugins/quota/quota.c --- a/src/plugins/quota/quota.c Tue Feb 07 18:26:50 2017 +0200 +++ b/src/plugins/quota/quota.c Tue Feb 07 20:41:41 2017 +0200 @@ -946,8 +946,15 @@ &count_current, &count_limit) < 0) return; - bytes_before = bytes_current - ctx->bytes_used; - count_before = count_current - ctx->count_used; + if (ctx->bytes_used > 0 && bytes_current < (uint64_t)ctx->bytes_used) + bytes_before = 0; + else + bytes_before = 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; for (i = 0; i < count; i++) { if (quota_warning_match(&warnings[i], bytes_before, bytes_current,