Mercurial > dovecot > original-hg > dovecot-1.2
changeset 7369:fc296dfcfd29 HEAD
If uidlist writing fails, don't assert-crash.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 07 Mar 2008 07:38:23 +0200 |
parents | 750ff2eb83a0 |
children | d51565e31ceb |
files | src/plugins/fts-squat/squat-uidlist.c |
diffstat | 1 files changed, 10 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/fts-squat/squat-uidlist.c Fri Mar 07 05:17:56 2008 +0200 +++ b/src/plugins/fts-squat/squat-uidlist.c Fri Mar 07 07:38:23 2008 +0200 @@ -254,9 +254,11 @@ *size_r = (bufp - buf) << 2 | packed_flags; return 0; } + } else if (unlikely(output->offset <= uid_list[0])) { + i_assert(output->closed); + return -1; } else { i_assert(list->uid_count > 1); - i_assert(output->offset > uid_list[0]); offset = (output->offset - uid_list[0]) << 1; } uid_list++; @@ -800,10 +802,13 @@ if (ctx->uidlist->corrupted) return -1; - o_stream_seek(ctx->output, 0); - o_stream_send(ctx->output, &ctx->build_hdr, sizeof(ctx->build_hdr)); - o_stream_seek(ctx->output, ctx->build_hdr.used_file_size); - o_stream_flush(ctx->output); + if (!ctx->output->closed) { + o_stream_seek(ctx->output, 0); + o_stream_send(ctx->output, + &ctx->build_hdr, sizeof(ctx->build_hdr)); + o_stream_seek(ctx->output, ctx->build_hdr.used_file_size); + o_stream_flush(ctx->output); + } if (ctx->output->last_failed_errno != 0) { errno = ctx->output->last_failed_errno;