Mercurial > dovecot > original-hg > dovecot-1.2
changeset 3047:89c49afa57fd HEAD
We didn't handle properly missing boundaries.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 07 Jan 2005 00:26:40 +0200 |
parents | c35e02d5724a |
children | 12fc3c22ffe8 |
files | src/lib-mail/message-parser.c |
diffstat | 1 files changed, 15 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-mail/message-parser.c Thu Jan 06 23:40:26 2005 +0200 +++ b/src/lib-mail/message-parser.c Fri Jan 07 00:26:40 2005 +0200 @@ -381,14 +381,12 @@ return NULL; } -/* read until next boundary is found. if skip_over = FALSE, stop at the - [\r]\n before the boundary, otherwise leave it right after the known - boundary so the ending "--" can be checked. */ +/* read until next boundary is found. stops at the [\r]\n before the + boundary. */ static struct message_boundary * message_find_boundary(struct istream *input, struct message_boundary *boundaries, - struct message_size *msg_size, int skip_over, - int *has_nuls) + struct message_size *msg_size, int *has_nuls) { struct message_boundary *boundary; const unsigned char *msg; @@ -476,10 +474,7 @@ 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; - } else if (line_start > 0 && msg[line_start-1] == '\n') { + if (line_start > 0 && msg[line_start-1] == '\n') { /* leave the \r\n before the boundary */ line_start--; msg_size->lines--; @@ -515,7 +510,7 @@ boundary = NULL; } else { boundary = message_find_boundary(parser_ctx->input, boundaries, - msg_size, FALSE, has_nuls); + msg_size, has_nuls); } return boundary == NULL ? NULL : boundary->part; @@ -534,14 +529,21 @@ int end_boundary; boundary = message_find_boundary(parser_ctx->input, boundaries, - boundary_size, TRUE, has_nuls); + boundary_size, has_nuls); if (boundary == NULL) return NULL; /* now, see if it's end boundary */ end_boundary = FALSE; - if (i_stream_read_data(parser_ctx->input, &msg, &size, 1) > 0) - end_boundary = msg[0] == '-' && msg[1] == '-'; + if (i_stream_read_data(parser_ctx->input, &msg, &size, + 2 + boundary->len + 1) > 0) { + end_boundary = msg[boundary->len + 2] == '-' && + msg[boundary->len + 2 + 1] == '-'; + } + + /* now, the boundary we found may not be what we expected. + change boundary_size to be the found boundary's parent part */ + boundary_size = &boundary->part->body_size; /* skip the rest of the line */ message_skip_line(parser_ctx->input, boundary_size,