From: Timo Sirainen Date: Wed, 15 Sep 2010 15:07:15 +0000 (+0100) Subject: lib-mail: Previous message parser optimization caused infinite looping with some... X-Git-Tag: 2.0.3~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9042caa1ad49a3b44cf2b63cbcc66b00c27bab4d;p=thirdparty%2Fdovecot%2Fcore.git lib-mail: Previous message parser optimization caused infinite looping with some mails. --- diff --git a/src/lib-mail/message-parser.c b/src/lib-mail/message-parser.c index f468ce2948..ce50b1024c 100644 --- a/src/lib-mail/message-parser.c +++ b/src/lib-mail/message-parser.c @@ -369,15 +369,19 @@ static int parse_next_body_to_boundary(struct message_parser_ctx *ctx, } } - if (next == NULL) { + if (next != NULL) { + /* found / need more data */ + i_assert(ret >= 0); + i_assert(!(ret == 0 && full)); + } else if (boundary_start == 0) { + /* no linefeeds in this block. we can just skip it. */ + ret = 0; + boundary_start = block_r->size; + } else { /* the boundary wasn't found from this data block, we'll need more data. */ ret = 0; ctx->want_count = (block_r->size - boundary_start) + 1; - } else { - /* found / need more data */ - i_assert(ret >= 0); - i_assert(!(ret == 0 && full)); } if (ret > 0 || (ret == 0 && !ctx->eof)) {