FYI,

I've just pushed a fix for this problem to the dbmail_2_2 tree.

patch attached.



Gordan Bobic wrote:
> Marc Dirix wrote:
>> I think 2.2.10 does not seem to suffer from it.
>>
>> As I tried to downgrade earlier I got into problems with strtoul.
> 
> I just rolled back to 2.2.9 and the problem disappeared. Yet another 
> upgrade exclusion in my yum.conf. Thanks to those of you who pointed out 
> that the bug was introduced in 2.2.11.
> 
> Gordan
> _______________________________________________
> DBmail mailing list
> [email protected]
> http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail
> 


-- 
  ________________________________________________________________
  Paul Stevens                                      paul at nfg.nl
  NET FACILITIES GROUP                     GPG/PGP: 1024D/11F8CD31
  The Netherlands________________________________http://www.nfg.nl
>From c8bf103cfd18f3f4a228b299c257ffecac3e0012 Mon Sep 17 00:00:00 2001
From: Paul J Stevens <[email protected]>
Date: Wed, 1 Jul 2009 18:48:21 +0200
Subject: [PATCH] backport fix to prevent showing mailboxes more than once during LIST/LSUB

---
 imapcommands.c |   51 ++++++++++++++++++++++++++++++++-------------------
 1 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/imapcommands.c b/imapcommands.c
index 202098b..cd51262 100644
--- a/imapcommands.c
+++ b/imapcommands.c
@@ -678,10 +678,16 @@ int _ic_unsubscribe(struct ImapSession *self)
  *
  * executes a list command
  */
+static int dm_strcmpdata(gconstpointer a, gconstpointer b, gpointer data UNUSED)
+{
+        return strcmp((const char *)a, (const char *)b);
+}
+
 int _ic_list(struct ImapSession *self)
 {
 	imap_userdata_t *ud = (imap_userdata_t *) self->ci->userData;
 	u64_t *children = NULL;
+	GTree *shown = NULL;
 	int result;
 	size_t slen;
 	unsigned i;
@@ -738,6 +744,8 @@ int _ic_list(struct ImapSession *self)
 
 	mb = g_new0(mailbox_t,1);
 
+	shown = g_tree_new_full((GCompareDataFunc)dm_strcmpdata,NULL,(GDestroyNotify)g_free,NULL);
+
 	for (i = 0; i < nchildren; i++) {
 		gboolean show = FALSE;
 		if ((db_getmailbox_list_result(children[i], ud->userid, mb) != 0))
@@ -778,31 +786,36 @@ int _ic_list(struct ImapSession *self)
 			show = TRUE;
 		}
 
-		if (! show) continue;
-	
-		plist = NULL;
-		if (mb->no_select)
-			plist = g_list_append(plist, g_strdup("\\noselect"));
-		if (mb->no_inferiors)
-			plist = g_list_append(plist, g_strdup("\\noinferiors"));
-		if (mb->no_children)
-			plist = g_list_append(plist, g_strdup("\\hasnochildren"));
-		else
-			plist = g_list_append(plist, g_strdup("\\haschildren"));
-		
-		/* show */
-		pstring = dbmail_imap_plist_as_string(plist);
-		dbmail_imap_session_printf(self, "* %s %s \"%s\" \"%s\"\r\n", thisname, 
-				pstring, MAILBOX_SEPARATOR, mb->name);
-		
-		g_list_destroy(plist);
-		g_free(pstring);
+		if (show && (! g_tree_lookup(shown, mb->name))) {
+			char *s = g_strdup(mb->name);
+			g_tree_insert(shown, s, s);
+			plist = NULL;
+			if (mb->no_select)
+				plist = g_list_append(plist, g_strdup("\\noselect"));
+			if (mb->no_inferiors)
+				plist = g_list_append(plist, g_strdup("\\noinferiors"));
+			if (mb->no_children)
+				plist = g_list_append(plist, g_strdup("\\hasnochildren"));
+			else
+				plist = g_list_append(plist, g_strdup("\\haschildren"));
+			
+			/* show */
+			pstring = dbmail_imap_plist_as_string(plist);
+			dbmail_imap_session_printf(self, "* %s %s \"%s\" \"%s\"\r\n", thisname, 
+					pstring, MAILBOX_SEPARATOR, mb->name);
+			
+			g_list_destroy(plist);
+			g_free(pstring);
+		}
 	}
 
 
 	if (children)
 		g_free(children);
 
+	if (shown)
+		g_tree_destroy(shown);
+
 	g_free(pattern);
 	g_free(mb);
 	dbmail_imap_session_printf(self, "%s OK %s completed\r\n", self->tag, thisname);
-- 
1.6.0.4

_______________________________________________
DBmail mailing list
[email protected]
http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail

Reply via email to