Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6586:d6b2343238f9 HEAD
Handle lines longer than 8192 bytes without going to infinite loop.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 21 Oct 2007 15:13:28 +0300 |
parents | a9dfe05dfadd |
children | 06e3cff76570 |
files | src/lib-mail/message-parser.c |
diffstat | 1 files changed, 14 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-mail/message-parser.c Sun Oct 21 14:32:34 2007 +0300 +++ b/src/lib-mail/message-parser.c Sun Oct 21 15:13:28 2007 +0300 @@ -113,10 +113,10 @@ ret = i_stream_read_data(ctx->input, &block_r->data, &block_r->size, ctx->want_count); - if (ret == -1) - return -1; + if (ret <= 0) { + if (ret < 0) + return ret; - if (ret == 0) { if (!ctx->input->eof) { i_assert(!ctx->input->blocking); return 0; @@ -341,6 +341,10 @@ /* we can skip the first lines. input buffer can't be full anymore. */ full = FALSE; + } else if (next_line_idx == block_r->size) { + /* no linefeeds in this block. we can just skip it. */ + boundary_start = block_r->size; + full = FALSE; } ret = boundary_line_find(ctx, block_r->data + next_line_idx, @@ -716,17 +720,13 @@ while ((ret = ctx->parse_next_block(ctx, block_r)) == 0) { ret = message_parser_read_more(ctx, block_r); - if (ret <= 0) { - i_assert(ret != -2); - - if (ret == 0) { - i_assert(!ctx->input->blocking); - return 0; - } - if (ret < 0) { - i_assert(!eof); - eof = TRUE; - } + if (ret == 0) { + i_assert(!ctx->input->blocking); + return 0; + } + if (ret == -1) { + i_assert(!eof); + eof = TRUE; } }