[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-save.c, 1.94.2.12, 1.94.2.13

tss at dovecot.org tss at dovecot.org
Thu Apr 26 20:03:37 EEST 2007


Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv13582

Modified Files:
      Tag: branch_1_0
	mbox-save.c 
Log Message:
Another try at fixing the X-Delivery-ID problem.



Index: mbox-save.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-save.c,v
retrieving revision 1.94.2.12
retrieving revision 1.94.2.13
diff -u -d -r1.94.2.12 -r1.94.2.13
--- mbox-save.c	25 Apr 2007 13:30:32 -0000	1.94.2.12
+++ mbox-save.c	26 Apr 2007 17:03:34 -0000	1.94.2.13
@@ -48,6 +48,7 @@
 	char last_char;
 
 	struct mbox_md5_context *mbox_md5_ctx;
+	unsigned int x_delivery_id_pos;
 
 	unsigned int synced:1;
 	unsigned int failed:1;
@@ -368,23 +369,9 @@
 	md5_get_digest(buf->data, buf->used, md5_result);
 
 	str_append(ctx->headers, "X-Delivery-ID: ");
+	ctx->x_delivery_id_pos = str_len(ctx->headers);
 	base64_encode(md5_result, sizeof(md5_result), ctx->headers);
 	str_append_c(ctx->headers, '\n');
-
-	if (ctx->mbox_md5_ctx != NULL) {
-		struct message_header_line hdr;
-
-		memset(&hdr, 0, sizeof(hdr));
-		hdr.name = "X-Delivery-ID";
-		hdr.name_len = strlen(hdr.name);
-		hdr.middle = (const unsigned char *)": ";
-		hdr.middle_len = 2;
-		hdr.value = hdr.full_value = str_data(ctx->headers) +
-			hdr.name_len + hdr.middle_len;
-		hdr.value_len = hdr.full_value_len = str_len(ctx->headers) -
-			(hdr.name_len + hdr.middle_len + 1);
-		mbox_md5_continue(ctx->mbox_md5_ctx, &hdr);
-	}
 	t_pop();
 }
 
@@ -565,6 +552,22 @@
 	if (ctx->mbox_md5_ctx) {
 		unsigned char hdr_md5_sum[16];
 
+		if (ctx->x_delivery_id_pos != 0) {
+			struct message_header_line hdr;
+			const unsigned char *p;
+
+			memset(&hdr, 0, sizeof(hdr));
+			hdr.name = "X-Delivery-ID";
+			hdr.name_len = strlen(hdr.name);
+			hdr.middle = (const unsigned char *)": ";
+			hdr.middle_len = 2;
+			hdr.value = hdr.full_value = str_data(ctx->headers) +
+				ctx->x_delivery_id_pos;
+
+			for (p = hdr.value; *p != '\n'; p++) ;
+			hdr.value_len = hdr.full_value_len = p - hdr.value;
+			mbox_md5_continue(ctx->mbox_md5_ctx, &hdr);
+		}
 		mbox_md5_finish(ctx->mbox_md5_ctx, hdr_md5_sum);
 		mail_index_update_ext(ctx->trans, ctx->seq,
 				      ctx->mbox->ibox.md5hdr_ext_idx,



More information about the dovecot-cvs mailing list