changeset 5305:43d3955ce03f HEAD

Fixes to counting MIME part sizes
author Timo Sirainen <tss@iki.fi>
date Wed, 14 Mar 2007 16:36:44 +0200
parents afcb29d8faff
children 1c6c3d9494fb
files src/lib-mail/message-parser.c
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-mail/message-parser.c	Wed Mar 14 15:59:05 2007 +0200
+++ b/src/lib-mail/message-parser.c	Wed Mar 14 16:36:44 2007 +0200
@@ -245,7 +245,7 @@
 
 static int parse_part_finish(struct message_parser_ctx *ctx,
 			     struct message_boundary *boundary,
-			     struct message_block *block_r)
+			     struct message_block *block_r, bool first_line)
 {
 	struct message_part *part;
 
@@ -278,8 +278,11 @@
 
 	/* the boundary itself should already be in buffer. add that. */
 	block_r->data = i_stream_get_data(ctx->input, &block_r->size);
-	i_assert(block_r->size >= 2 + boundary->len);
-	block_r->size = 2 + boundary->len;
+	i_assert(block_r->size >= ctx->skip + 2 + boundary->len +
+		 (first_line ? 0 : 1));
+	block_r->data += ctx->skip;
+	/* [\n]--<boundary> */
+	block_r->size = (first_line ? 0 : 1) + 2 + boundary->len;
 	parse_body_add_block(ctx, block_r);
 
 	ctx->parse_next_block = parse_next_body_skip_boundary_line;
@@ -311,7 +314,7 @@
 			if (ret == 0)
 				return 0;
 
-			return parse_part_finish(ctx, boundary, block_r);
+			return parse_part_finish(ctx, boundary, block_r, TRUE);
 		}
 	}
 
@@ -357,7 +360,7 @@
 	if (block_r->size != 0)
 		parse_body_add_block(ctx, block_r);
 	return ret <= 0 ? ret :
-		parse_part_finish(ctx, boundary, block_r);
+		parse_part_finish(ctx, boundary, block_r, FALSE);
 }
 
 static int parse_next_body_to_eof(struct message_parser_ctx *ctx,