Subject: Possible bug...

From: Adrian Wise <[email-masked]>
Date: Wed, 14 May 2003 10:00:28 +0100

I'm new to this code so I may be wrong, but I think I came
across a small bug in imap4r1.c.

Around line 325 there are two tests to see if a string is
"LIST", and then "LSUB". In the case of the check on
lower-case letters, in both tests cmd[1] is checked twice.

See the context diff below.

I'm looking at the "imap-2002c1" release.

Adrian

*** imap4r1.c   2003-03-24 16:55:04.000000000 +0000
--- imap4r1.c.fix       2003-05-13 00:37:08.000000000 +0100
***************
*** 321,331 ****
         ((cmd[0] == 'L') || (cmd[0] == 'l')) && !cmd[4]) {
                                 /* yes, convert LIST -> RLIST */
         if (((cmd[1] == 'I') || (cmd[1] == 'i')) &&
!         ((cmd[2] == 'S') || (cmd[1] == 's')) &&
           ((cmd[3] == 'T') || (cmd[3] == 't'))) cmd = "RLIST";
                                 /* and convert LSUB -> RLSUB */
         else if (((cmd[1] == 'S') || (cmd[1] == 's')) &&
!              ((cmd[2] == 'U') || (cmd[1] == 'u')) &&
                ((cmd[3] == 'B') || (cmd[3] == 'b'))) cmd = "RLSUB";
       }
       imap_send (stream,cmd,args);
--- 321,331 ----
         ((cmd[0] == 'L') || (cmd[0] == 'l')) && !cmd[4]) {
                                 /* yes, convert LIST -> RLIST */
         if (((cmd[1] == 'I') || (cmd[1] == 'i')) &&
!         ((cmd[2] == 'S') || (cmd[2] == 's')) &&
           ((cmd[3] == 'T') || (cmd[3] == 't'))) cmd = "RLIST";
                                 /* and convert LSUB -> RLSUB */
         else if (((cmd[1] == 'S') || (cmd[1] == 's')) &&
!              ((cmd[2] == 'U') || (cmd[2] == 'u')) &&
                ((cmd[3] == 'B') || (cmd[3] == 'b'))) cmd = "RLSUB";
       }
       imap_send (stream,cmd,args);

-- 
------------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/imap/c-client-list.html
------------------------------------------------------------------

---

From: Mark Crispin <[email-masked]>
Date: Wed, 14 May 2003 06:31:00 -0700 (PDT)

Thank you for reporting this issue.

Your suggested fix is correct.  Fortunately, the only way that an
application would encounter this bug is if it called imap_list_work()
itself (against the rules, since that's an internal routine).  The only
c-client calls to imap_list_work() use the upper-case forms.

I will, however, fix this anyway.

-- Mark --

http://staff.washington.edu/mrc
Science does not emerge from voting, party politics, or public debate.