Subject: IMAP alerts broken

From: Michail Vidiassov <[email-masked]>
Date: Tue, 9 Dec 2003 00:30:11 +0300 (MSK)

Dear gurus,

I run pine 4.58 on FreeBSD  4.9.

When I try to access a user mailbox which is overquota, I receive
the following error message:
----------------------------
          ***********************************************************
          * What follows is an advisory message.  After reading it  *
          * simply hit "Return" to continue your Pine session.      *
          *                                                         *
          * To review this message later, press 'J' from the        *
          * MAIN MENU.                                              *
          ***********************************************************

Alert received while accessing "{host.domain}user.name":  Alert
received while accessing "{host.domain}user.name"
----------------------------

Note the repeated text. It is not a cut-n-paste error.

I think that the problem is in the following piece of code from
imap.c:

    else if(!strncmp(string, "[ALERT]", 7))
      q_status_message2(SM_MODAL, 3, 3,
                        "Alert received while accessing \"%.200s\":  %.200s",
                        (stream && stream->mailbox)
                          ? stream->mailbox : "-no folder-",
                        rfc1522_decode((unsigned char *)tmp_20k_buf,
                                       SIZEOF_20KBUF, string, NULL));

The problem is that tmp_20k_buf is used both by
rfc1522_decode to store the decoded alert message from server and by
q_status_message2 to sprintf the pine advisory message into.

May be other OS's do not experience the bug, as their sprintf behaves
differently.

To get rid of the error one may use the second half
of tmp_20k_buf to store decoded text:

--- pine/imap.c.orig    Thu May  8 21:32:18 2003
+++ pine/imap.c Mon Dec  8 19:26:38 2003
@@ -365,8 +365,8 @@
                        "Alert received while accessing \"%.200s\":  %.200s",
                        (stream && stream->mailbox)
                          ? stream->mailbox : "-no folder-",
-                       rfc1522_decode((unsigned char *)tmp_20k_buf,
-                                      SIZEOF_20KBUF, string, NULL));
+                       rfc1522_decode((unsigned char *)(tmp_20k_buf+10000),
+                                      SIZEOF_20KBUF-10000, string, NULL));
     else if(!strncmp(string, "[UNSEEN ", 8)){
        char *p;
        long  n = 0;

		Sincerely, Michail
-- 
-----------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/pine/pine-info/
-----------------------------------------------------------------

---

From: Steve Hubert <[email-masked]>
Date: Mon, 8 Dec 2003 17:08:12 -0800 (PST)

Thanks, your fix will be in next version of Pine.

Steve Hubert <[email-masked]>
Networks and Distributed Computing, Univ. of Washington, Seattle