]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Fixed infinite looping when parsing some (not all) broken multipart mails
authorTimo Sirainen <tss@iki.fi>
Thu, 21 Aug 2008 23:24:38 +0000 (02:24 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 21 Aug 2008 23:24:38 +0000 (02:24 +0300)
that didn't end with proper --boundary--.

--HG--
branch : HEAD

src/lib-mail/message-parser.c

index bef73345f25878fed0380d1203c67434ea89eb1a..6a84c74cc44565b702a16b18f0411a452ace6bdc 100644 (file)
@@ -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));