From: Timo Sirainen Date: Sat, 3 May 2003 17:28:20 +0000 (+0300) Subject: We stopped parsing message if there was a line longer than input buffer X-Git-Tag: 1.1.alpha1~4693 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1002b7b24fa2447639c66f97078021dad1fda146;p=thirdparty%2Fdovecot%2Fcore.git We stopped parsing message if there was a line longer than input buffer (8192 bytes). --HG-- branch : HEAD --- diff --git a/src/lib-mail/message-parser.c b/src/lib-mail/message-parser.c index 959bce8b35..17ef7fec4f 100644 --- a/src/lib-mail/message-parser.c +++ b/src/lib-mail/message-parser.c @@ -350,7 +350,8 @@ message_find_boundary(struct istream *input, if (msg[i] != '\n') continue; - if (i >= line_start+2 && msg[line_start] == '-' && + if (line_start != (size_t)-1 && + i >= line_start+2 && msg[line_start] == '-' && msg[line_start+1] == '-') { /* possible boundary */ boundary = boundary_find(boundaries, @@ -372,21 +373,26 @@ message_find_boundary(struct istream *input, if (boundary != NULL) break; - if (i - line_start > 128 && - msg[line_start] == '-' && msg[line_start+1] == '-') { + if (line_start == (size_t)-1) { + /* continued long line, continue skipping over it */ + } else if (i - line_start > 128) { /* long partial line, see if it's a boundary. RFC-2046 says that the boundaries must be 70 chars without "--" or less. We allow a bit larger.. */ - boundary = boundary_find(boundaries, - msg + line_start + 2, - i - line_start - 2); - if (boundary != NULL) - break; + if (msg[line_start] == '-' && + msg[line_start+1] == '-') { + boundary = boundary_find(boundaries, + msg + line_start + 2, + i - line_start - 2); + if (boundary != NULL) + break; + } /* nope, we can skip over the line, just leave the last char since it may be \r */ i--; + line_start = (size_t)-1; } else { /* leave the last line to buffer, it may be boundary */ @@ -403,7 +409,8 @@ message_find_boundary(struct istream *input, startpos = size - i; } - if (boundary == NULL && line_start+2 <= size && + if (boundary == NULL && + line_start != (size_t)-1 && line_start+2 <= size && msg[line_start] == '-' && msg[line_start+1] == '-') { /* possible boundary without line feed at end */ boundary = boundary_find(boundaries, @@ -412,6 +419,7 @@ message_find_boundary(struct istream *input, } if (boundary != NULL) { + i_assert(line_start != (size_t)-1); if (skip_over) { /* leave the pointer right after the boundary */ line_start += 2 + boundary->len;