]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-mail: Previous message parser optimization caused infinite looping with some...
authorTimo Sirainen <tss@iki.fi>
Wed, 15 Sep 2010 15:07:15 +0000 (16:07 +0100)
committerTimo Sirainen <tss@iki.fi>
Wed, 15 Sep 2010 15:07:15 +0000 (16:07 +0100)
src/lib-mail/message-parser.c

index f468ce2948f394defcea4dec8631a236e66795ae..ce50b1024c1abfc6269b96652e5f4642e2e352f5 100644 (file)
@@ -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)) {