dovecot: Handle lines longer than 8192 bytes without going to in...
dovecot at dovecot.org
dovecot at dovecot.org
Sun Oct 21 15:13:31 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/d6b2343238f9
changeset: 6586:d6b2343238f9
user: Timo Sirainen <tss at iki.fi>
date: Sun Oct 21 15:13:28 2007 +0300
description:
Handle lines longer than 8192 bytes without going to infinite loop.
diffstat:
1 file changed, 15 insertions(+), 15 deletions(-)
src/lib-mail/message-parser.c | 30 +++++++++++++++---------------
diffs (54 lines):
diff -r a9dfe05dfadd -r d6b2343238f9 src/lib-mail/message-parser.c
--- a/src/lib-mail/message-parser.c Sun Oct 21 14:32:34 2007 +0300
+++ b/src/lib-mail/message-parser.c Sun Oct 21 15:13:28 2007 +0300
@@ -113,10 +113,10 @@ static int message_parser_read_more(stru
ret = i_stream_read_data(ctx->input, &block_r->data,
&block_r->size, ctx->want_count);
- if (ret == -1)
- return -1;
-
- if (ret == 0) {
+ if (ret <= 0) {
+ if (ret < 0)
+ return ret;
+
if (!ctx->input->eof) {
i_assert(!ctx->input->blocking);
return 0;
@@ -340,6 +340,10 @@ static int parse_next_body_to_boundary(s
if (boundary_start != 0) {
/* we can skip the first lines. input buffer can't be
full anymore. */
+ full = FALSE;
+ } else if (next_line_idx == block_r->size) {
+ /* no linefeeds in this block. we can just skip it. */
+ boundary_start = block_r->size;
full = FALSE;
}
@@ -716,17 +720,13 @@ int message_parser_parse_next_block(stru
while ((ret = ctx->parse_next_block(ctx, block_r)) == 0) {
ret = message_parser_read_more(ctx, block_r);
- if (ret <= 0) {
- i_assert(ret != -2);
-
- if (ret == 0) {
- i_assert(!ctx->input->blocking);
- return 0;
- }
- if (ret < 0) {
- i_assert(!eof);
- eof = TRUE;
- }
+ if (ret == 0) {
+ i_assert(!ctx->input->blocking);
+ return 0;
+ }
+ if (ret == -1) {
+ i_assert(!eof);
+ eof = TRUE;
}
}
More information about the dovecot-cvs
mailing list