[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-save.c, 1.110, 1.111

tss at dovecot.org tss at dovecot.org
Thu Apr 26 21:26:54 EEST 2007


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

Modified Files:
	mbox-save.c 
Log Message:
If pop3_uidl_format=%m, it wasn't cached correctly when saving new messages
(eg. with deliver). X-Delivery-ID wasn't used in the MD5 sum, causing
duplicates when POP3 recalculated the MD5 sum later.



Index: mbox-save.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-save.c,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -d -r1.110 -r1.111
--- mbox-save.c	17 Apr 2007 17:18:04 -0000	1.110
+++ mbox-save.c	26 Apr 2007 18:26:52 -0000	1.111
@@ -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;
@@ -370,6 +371,7 @@
 	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');
 	t_pop();
@@ -415,6 +417,8 @@
 	save_flags = (flags & ~MAIL_RECENT) | MAIL_RECENT;
 	str_truncate(ctx->headers, 0);
 	if (ctx->synced) {
+		if (ctx->mbox->mbox_save_md5)
+			ctx->mbox_md5_ctx = mbox_md5_init();
 		if (ctx->output->offset == 0) {
 			/* writing the first mail. Insert X-IMAPbase as well. */
 			str_printfa(ctx->headers, "X-IMAPbase: %u %010u\n",
@@ -482,8 +486,6 @@
 			 MAIL_STORAGE_FLAG_SAVE_CRLF) != 0 ?
 			o_stream_create_crlf(default_pool, ctx->output) :
 			o_stream_create_lf(default_pool, ctx->output);
-		if (ctx->mbox->mbox_save_md5 && ctx->synced)
-			ctx->mbox_md5_ctx = mbox_md5_init();
 	}
 
 	*ctx_r = &ctx->ctx;
@@ -555,6 +557,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