dovecot-2.2: mdbox: Make sure rebuilding doesn't try to add a co...

dovecot at dovecot.org dovecot at dovecot.org
Thu Jul 2 09:08:57 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/ae19beafa55b
changeset: 18899:ae19beafa55b
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jul 02 11:06:04 2015 +0200
description:
mdbox: Make sure rebuilding doesn't try to add a copy of the message too many times.
Currently it just silently overflowed the 16bit refcount, which caused
problems later.

diffstat:

 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c |  6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diffs (30 lines):

diff -r 7a6452869981 -r ae19beafa55b src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
--- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c	Tue Jun 30 14:26:00 2015 +0300
+++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c	Thu Jul 02 11:06:04 2015 +0200
@@ -20,6 +20,8 @@
 #include <dirent.h>
 #include <unistd.h>
 
+#define REBUILD_MAX_REFCOUNT 32768
+
 struct mdbox_rebuild_msg {
 	struct mdbox_rebuild_msg *guid_hash_next;
 
@@ -458,7 +460,8 @@
 			   GUID exists multiple times */
 		}
 
-		if (rec != NULL) T_BEGIN {
+		if (rec != NULL &&
+		    rec->refcount < REBUILD_MAX_REFCOUNT) T_BEGIN {
 			/* keep this message. add it to mailbox index. */
 			i_assert(map_uid != 0);
 			rec->refcount++;
@@ -758,6 +761,7 @@
 	mail_index_update_ext(ctx->prev_msg.trans, seq, mbox->guid_ext_id,
 			      msg->guid_128, NULL);
 
+	i_assert(msg->refcount == 0);
 	msg->refcount++;
 	return 0;
 }


More information about the dovecot-cvs mailing list