[dovecot-cvs] dovecot/src/lib-mail message-parser.c,1.81,1.82

tss at dovecot.org tss at dovecot.org
Wed Mar 14 16:36:46 EET 2007


Update of /var/lib/cvs/dovecot/src/lib-mail
In directory talvi:/tmp/cvs-serv7181

Modified Files:
	message-parser.c 
Log Message:
Fixes to counting MIME part sizes



Index: message-parser.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/message-parser.c,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- message-parser.c	8 Mar 2007 13:22:53 -0000	1.81
+++ message-parser.c	14 Mar 2007 14:36:44 -0000	1.82
@@ -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,



More information about the dovecot-cvs mailing list