Mercurial > dovecot > core-2.2
changeset 14602:8a4e5e5d82b5
message header parser: Fixed handling very long multiline headers.
If the header's line fit exactly to input stream's buffer so that the parser
couldn't see the following character, it assumed that the header ended.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 20 Jun 2012 01:40:14 +0300 |
parents | c34d4e3ff342 |
children | 49607e4a97d4 |
files | src/lib-mail/message-header-parser.c |
diffstat | 1 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-mail/message-header-parser.c Wed Jun 20 00:48:08 2012 +0300 +++ b/src/lib-mail/message-header-parser.c Wed Jun 20 01:40:14 2012 +0300 @@ -159,6 +159,17 @@ break; } } + if (i == min_pos && (msg[size-1] == '\r' || + msg[size-1] == '\n')) { + /* we may or may not have a full header, + but we don't know until we get the + next character. leave out the + linefeed and finish the header on + the next run. */ + size--; + if (size > 0 && msg[size-1] == '\r') + size--; + } continues = TRUE; } @@ -201,7 +212,10 @@ } } - if (i < parse_size) { + if (i < parse_size && i+1 == size && ret == -2) { + /* we don't know if the line continues. */ + i++; + } else if (i < parse_size) { /* got a line */ if (ctx->skip_line) { /* skipping a line with a huge header name */