From: Timo Sirainen Date: Sun, 20 Jun 2004 06:14:00 +0000 (+0300) Subject: Make sure headers end with LF X-Git-Tag: 1.1.alpha1~3912 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb3fca0e205a2410aa9a2fdf6874e0a84fc015b2;p=thirdparty%2Fdovecot%2Fcore.git Make sure headers end with LF --HG-- branch : HEAD --- diff --git a/src/lib-storage/mail-save.c b/src/lib-storage/mail-save.c index 69e85f65a6..ab09caf597 100644 --- a/src/lib-storage/mail-save.c +++ b/src/lib-storage/mail-save.c @@ -94,7 +94,7 @@ static int save_headers(struct istream *input, struct ostream *output, { struct message_header_parser_ctx *hdr_ctx; struct message_header_line *hdr; - int ret = 0; + int last_newline = TRUE, ret = 0; hdr_ctx = message_parse_header_init(input, NULL, FALSE); while ((hdr = message_parse_header_next(hdr_ctx)) != NULL) { @@ -114,10 +114,17 @@ static int save_headers(struct istream *input, struct ostream *output, (void)o_stream_send(output, hdr->value, hdr->value_len); if (!hdr->no_newline) write_func(output, "\n", 1); + last_newline = !hdr->no_newline; + } else { + last_newline = TRUE; } } if (ret >= 0) { + if (!last_newline) { + /* don't allow headers that don't terminate with \n */ + write_func(output, "\n", 1); + } if (header_callback(NULL, write_func, context) < 0) ret = -1;