The attached patch fixes an issue I was having with my system. Apparently the g_strncasecmp call was broken with glib 2.12.9. The call seemed to think that an empty buffer still matched "DONE". That caused all my connection to go into a bogus state.

Upgrading to glib 2.12.12 (current version available with an updated ports) resolves the issue with the code as is, but some systems with 2.12.11 (I tried this verision - but was still broken) and earlier (mine was 2.12.9 to start) will have trouble with this. Perhaps adding the strlen check will work around the glib bug, but I didn't try that before my system was up to 2.12.12.

This patch uses the standard strncmp call and also puts in a check to make sure the buffer has at least 5 bytes to look at (DONE[+CR]+LF). I'm not sure what the differences are on the 2 calls - but if nothing else the strlen check can't hurt.

-Jon
Index: dbmail-imapsession.c
===================================================================
--- dbmail-imapsession.c        (revision 2684)
+++ dbmail-imapsession.c        (working copy)
@@ -2007,7 +2007,7 @@
                fgets(buffer, IDLE_BUFFER, ci->rx);
                alarm(0);
 
-               if (g_strncasecmp(buffer,"DONE",4)==0)
+               if (strlen(buffer) > 4 && strncmp(buffer,"DONE",4)==0)
                        break;
                else if (strlen(buffer) > 0) {
                        dbmail_imap_session_printf(self,"%s BAD Expecting 
DONE\r\n", self->tag);

_______________________________________________
Dbmail-dev mailing list
[email protected]
http://twister.fastxs.net/mailman/listinfo/dbmail-dev

Reply via email to