Trash Plugin bugs
dovecot v2.2.16
I've found a few bugs in Trash plugin.
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; }
- 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);
- 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.
- Trash plugin does not check 'unlimited' values in bytes_ceil/count_ceil and may overflow them when add expunged size/messages check any overflow
ctx->bytes_ceil += size_expunged;
ctx->count_ceil += expunged_count;
if (ctx->bytes_ceil > ((uint64_t)-1 - size_expunged)) {
ctx->bytes_ceil = (uint64_t)-1;
} else {
ctx->bytes_ceil += size_expunged;
}
if (ctx->count_ceil > ((uint64_t)-1 - expunged_count)) {
ctx->count_ceil = (uint64_t)-1;
} else {
ctx->count_ceil += expunged_count;
}
Attached the last patch.
Regards, Alexei
Hello Timo,
Are you going to commit my patch to Dovecot v2.2.x? I sent it 2 weeks ago and still haven't seen it in http://hg.dovecot.org/dovecot-2.2/
Regards, Alexei
On 28 Apr 2015, at 15:42, Alexei Gradinari <alex2grad@gmail.com> wrote:
Hello Timo,
Are you going to commit my patch to Dovecot v2.2.x? I sent it 2 weeks ago and still haven't seen it in http://hg.dovecot.org/dovecot-2.2/
Committed, thanks!
http://hg.dovecot.org/dovecot-2.2/rev/e00f9e93a9a3 (the ret==0 check was already doing half of it, but since it didn't fully do it it could be removed entirely)
http://hg.dovecot.org/dovecot-2.2/rev/2dbee58a1a0d http://hg.dovecot.org/dovecot-2.2/rev/8898c5ea38f2
participants (2)
-
Alexei Gradinari
-
Timo Sirainen