From: Timo Sirainen Date: Thu, 21 Aug 2008 23:24:38 +0000 (+0300) Subject: Fixed infinite looping when parsing some (not all) broken multipart mails X-Git-Tag: 1.2.alpha1~58 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dbe3c45bc16f2afbeb431fe3f559cf9ddb0fad61;p=thirdparty%2Fdovecot%2Fcore.git Fixed infinite looping when parsing some (not all) broken multipart mails that didn't end with proper --boundary--. --HG-- branch : HEAD --- diff --git a/src/lib-mail/message-parser.c b/src/lib-mail/message-parser.c index bef73345f2..6a84c74cc4 100644 --- a/src/lib-mail/message-parser.c +++ b/src/lib-mail/message-parser.c @@ -336,6 +336,7 @@ static int parse_next_body_to_boundary(struct message_parser_ctx *ctx, } } + i_assert(block_r->size > 0); for (i = boundary_start = 0; i < block_r->size; i++) { /* skip to beginning of the next line. the first line was handled already. */ @@ -380,6 +381,9 @@ static int parse_next_body_to_boundary(struct message_parser_ctx *ctx, ret = 0; ctx->want_count = (block_r->size - boundary_start) + 1; } + } else if (ret == 0 && eof) { + /* we can't get any more data */ + ret = -1; } i_assert(!(ret == 0 && full));