Package: claws-mail
Version: 3.14.1-1.1
Severity: normal

Dear Maintainer,

The IMAP UIDs on one of my folders has increased to more than 2^31
which is causing claws-mail to repeatedly complain:

> folder.c:2265:Removed message 2147483647 from cache.

Upon examining folder.c I notice that, while cache_max_num,
folder_max_num, cache_cur_num and folder_cur_num ARE stored as unsigned
int (guint), in certain situations G_MAXINT is used as an "invalid
value". The attached patch changes this to G_MAXUINT. The patch also
changes usage of GPOINTER_TO_INT and GINT_TO_POINTER to their unsigned
variants.

-- System Information:
Debian Release: stretch/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 
'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.8.0-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_GB.utf8, LC_CTYPE=en_GB.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages claws-mail depends on:
ii  libatk1.0-0          2.22.0-1
ii  libc6                2.24-5
ii  libcairo2            1.14.6-1.1
ii  libcompfaceg1        1:1.5.2-5
ii  libdb5.3             5.3.28-12
ii  libdbus-1-3          1.10.12-1
ii  libdbus-glib-1-2     0.108-1
ii  libenchant1c2a       1.6.0-11+b1
ii  libetpan17           1.6-2
ii  libfontconfig1       2.11.0-6.7
ii  libfreetype6         2.6.3-3+b1
ii  libgdk-pixbuf2.0-0   2.36.0-1
ii  libglib2.0-0         2.50.2-1
ii  libgnutls30          3.5.6-4
ii  libgtk2.0-0          2.24.31-1
ii  libice6              2:1.0.9-1+b1
ii  libldap-2.4-2        2.4.44+dfsg-1
ii  liblockfile1         1.09-6
ii  libpango-1.0-0       1.40.3-3
ii  libpangocairo-1.0-0  1.40.3-3
ii  libpangoft2-1.0-0    1.40.3-3
ii  libpisock9           0.12.5-dfsg-2+b2
ii  libsasl2-2           2.1.27~72-g88d82a3+dfsg-1
ii  libsm6               2:1.2.2-1+b1
ii  xdg-utils            1.1.1-1
ii  zlib1g               1:1.2.8.dfsg-2+b3

Versions of packages claws-mail recommends:
pn  aspell-en | aspell-dictionary  <none>
ii  claws-mail-i18n                3.14.1-1.1
ii  xfonts-100dpi                  1:1.0.4+nmu1

Versions of packages claws-mail suggests:
ii  chromium [www-browser]             53.0.2785.143-1
pn  claws-mail-doc                     <none>
pn  claws-mail-tools                   <none>
ii  firefox-esr [www-browser]          45.5.0esr-1
pn  gedit | kwrite | mousepad | nedit  <none>
ii  lynx [www-browser]                 2.8.9dev11-1

-- no debconf information
diff -ur claws-mail-3.14.1.orig/src/folder.c claws-mail-3.14.1/src/folder.c
--- claws-mail-3.14.1.orig/src/folder.c	2016-11-28 19:28:22.869928915 +0000
+++ claws-mail-3.14.1/src/folder.c	2016-11-28 21:05:12.490606898 +0000
@@ -2196,22 +2196,22 @@
 		cache_list_last = g_slist_last(cache_list);
 		cache_max_num = ((MsgInfo *)cache_list_last->data)->msgnum;
 	} else {
-		cache_cur_num = G_MAXINT;
+		cache_cur_num = G_MAXUINT;
 		cache_max_num = 0;
 	}
 
 	if (folder_list_cur != NULL) {
 		GSList *folder_list_last;
 	
-		folder_cur_num = GPOINTER_TO_INT(folder_list_cur->data);
+		folder_cur_num = GPOINTER_TO_UINT(folder_list_cur->data);
 		folder_list_last = g_slist_last(folder_list);
-		folder_max_num = GPOINTER_TO_INT(folder_list_last->data);
+		folder_max_num = GPOINTER_TO_UINT(folder_list_last->data);
 	} else {
-		folder_cur_num = G_MAXINT;
+		folder_cur_num = G_MAXUINT;
 		folder_max_num = 0;
 	}
 
-	while ((cache_cur_num != G_MAXINT) || (folder_cur_num != G_MAXINT)) {
+	while ((cache_cur_num != G_MAXUINT) || (folder_cur_num != G_MAXUINT)) {
 		/*
 		 *  Message only exists in the folder
 		 *  Remember message for fetching
@@ -2240,8 +2240,8 @@
 			}
 			
 			if (add) {
-				new_list = g_slist_prepend(new_list, GINT_TO_POINTER(folder_cur_num));
-				debug_print("Remembered message %d for fetching\n", folder_cur_num);
+				new_list = g_slist_prepend(new_list, GUINT_TO_POINTER(folder_cur_num));
+				debug_print("Remembered message %u for fetching\n", folder_cur_num);
 			}
 
 			/* Move to next folder number */
@@ -2249,9 +2249,9 @@
 				folder_list_cur = folder_list_cur->next;
 
 			if (folder_list_cur != NULL)
-				folder_cur_num = GPOINTER_TO_INT(folder_list_cur->data);
+				folder_cur_num = GPOINTER_TO_UINT(folder_list_cur->data);
 			else
-				folder_cur_num = G_MAXINT;
+				folder_cur_num = G_MAXUINT;
 
 			continue;
 		}
@@ -2262,7 +2262,7 @@
 		 */
 		if (cache_cur_num < folder_cur_num) {
 			msgcache_remove_msg(item->cache, cache_cur_num);
-			debug_print("Removed message %d from cache.\n", cache_cur_num);
+			debug_print("Removed message %u from cache.\n", cache_cur_num);
 
 			/* Move to next cache number */
 			if (cache_list_cur)
@@ -2271,7 +2271,7 @@
 			if (cache_list_cur != NULL)
 				cache_cur_num = ((MsgInfo *)cache_list_cur->data)->msgnum;
 			else
-				cache_cur_num = G_MAXINT;
+				cache_cur_num = G_MAXUINT;
 
 			update_flags |= F_ITEM_UPDATE_MSGCNT | F_ITEM_UPDATE_CONTENT;
 
@@ -2291,7 +2291,7 @@
 				new_list = g_slist_prepend(new_list, GINT_TO_POINTER(msginfo->msgnum));
 				procmsg_msginfo_free(&msginfo);
 
-				debug_print("Remembering message %d to update...\n", folder_cur_num);
+				debug_print("Remembering message %u to update...\n", folder_cur_num);
 			} else if (msginfo) {
 				exists_list = g_slist_prepend(exists_list, msginfo);
 
@@ -2312,12 +2312,12 @@
 			if (cache_list_cur != NULL)
 				cache_cur_num = ((MsgInfo *)cache_list_cur->data)->msgnum;
 			else
-				cache_cur_num = G_MAXINT;
+				cache_cur_num = G_MAXUINT;
 
 			if (folder_list_cur != NULL)
-				folder_cur_num = GPOINTER_TO_INT(folder_list_cur->data);
+				folder_cur_num = GPOINTER_TO_UINT(folder_list_cur->data);
 			else
-				folder_cur_num = G_MAXINT;
+				folder_cur_num = G_MAXUINT;
 
 			continue;
 		}

Reply via email to