[dovecot-cvs] dovecot/src/lib-mail message-parser.c,1.78,1.79

tss at dovecot.org tss at dovecot.org
Tue Feb 6 13:24:44 UTC 2007


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

Modified Files:
	message-parser.c 
Log Message:
Fixes



Index: message-parser.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-mail/message-parser.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -d -r1.78 -r1.79
--- message-parser.c	6 Feb 2007 12:55:22 -0000	1.78
+++ message-parser.c	6 Feb 2007 13:24:42 -0000	1.79
@@ -243,6 +243,8 @@
 			     struct message_boundary *boundary,
 			     struct message_block *block_r)
 {
+	struct message_part *part;
+
 	if (boundary == NULL) {
 		/* message ended unexpectedly */
 		return -1;
@@ -250,13 +252,11 @@
 
 	/* get back to parent MIME part, summing the child MIME part sizes
 	   into parent's body sizes */
-	while (boundary->part != ctx->part) {
-		message_size_add(&ctx->part->parent->body_size,
-				 &ctx->part->body_size);
-		message_size_add(&ctx->part->parent->body_size,
-				 &ctx->part->header_size);
-		ctx->part = ctx->part->parent;
+	for (part = ctx->part; part != boundary->part; part = part->parent) {
+		message_size_add(&part->parent->body_size, &part->body_size);
+		message_size_add(&part->parent->body_size, &part->header_size);
 	}
+	ctx->part = part;
 
 	if (boundary->epilogue_found) {
 		/* this boundary isn't needed anymore */
@@ -332,10 +332,15 @@
 		}
 	}
 
-	if (i == block_r->size) {
+	if (i >= block_r->size) {
 		/* the boundary wasn't found from this data block,
 		   we'll need more data. */
-		ret = eof ? -1 : 0;
+		if (eof)
+			ret = -1;
+		else {
+			ret = 0;
+			ctx->want_count = i + 1;
+		}
 	}
 	i_assert(!(ret == 0 && full));
 
@@ -569,6 +574,7 @@
 	block_r->part = ctx->part;
 
 	if (ret < 0) {
+		i_assert(ctx->input->eof);
 		while (ctx->part->parent != NULL) {
 			message_size_add(&ctx->part->parent->body_size,
 					 &ctx->part->body_size);



More information about the dovecot-cvs mailing list