dovecot v2.2.16
I've found a few bugs in Trash plugin.
1. If Quota set only messages limit (without storage limit) then
Trash plugin does not expunge any message because Quota plugin sets
too_large_r=TRUE.
It's because quota_default_test_alloc function does not check if bytes_limit
is set.
/* if size is bigger than any limit, then
it is bigger than the lowest limit */
- if (size > bytes_limit) {
+ if (bytes_limit > 0 && size > bytes_limit) {
*too_large_r = TRUE;
break;
}
2. Trash plugin does not use bytes_ceil/count_ceil to calculate
size_needed/count_needed to expunge.
Trash plugin may expunge more messages that nedeed.
+ if (ctx->bytes_ceil!=(uint64_t)-1 &&
ctx->bytes_ceil < size + ctx->bytes_over) {
+ size_needed = size + ctx->bytes_over -
ctx->bytes_ceil;
+ }
+ if (ctx->count_ceil!=(uint64_t)-1 &&
ctx->count_ceil < 1 + ctx->count_over) {
+ count_needed = 1 + ctx->count_over -
ctx->count_ceil;
+ }
+
/* not enough space. try deleting some from mailbox. */
- ret = trash_try_clean_mails(ctx, size + ctx->bytes_over,
- 1 + ctx->count_over);
+ ret = trash_try_clean_mails(ctx, size_needed, count_needed);
3. Trash plugin does not check 'unlimited' values in
bytes_ceil/count_ceil and may overflow them
when add expunged size/messages
- ctx->bytes_ceil += size_expunged;
- ctx->count_ceil += expunged_count;
+ if (ctx->bytes_ceil!=(uint64_t)-1) {
+ ctx->bytes_ceil += size_expunged;
+ }
+ if (ctx->count_ceil!=(uint64_t)-1) {
+ ctx->count_ceil += expunged_count;
+ }
See attached patch.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: trash-plugin.patch
Type: application/octet-stream
Size: 1931 bytes
Desc: not available
URL:
<http://dovecot.org/pipermail/dovecot/attachments/20150409/9b5ca3ca/attachment.obj>