[asterisk-bugs] [Asterisk 0017306]: Sequencing numbers of IMAP email messages is incorrect

Asterisk Bug Tracker noreply at bugs.digium.com
Mon May 10 23:40:40 CDT 2010


A NOTE has been added to this issue. 
====================================================================== 
https://issues.asterisk.org/view.php?id=17306 
====================================================================== 
Reported By:                uxbod
Assigned To:                
====================================================================== 
Project:                    Asterisk
Issue ID:                   17306
Category:                   Applications/app_voicemail/IMAP
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     acknowledged
Asterisk Version:           1.6.2.6 
JIRA:                       SWP-1432 
Regression:                 No 
Reviewboard Link:            
SVN Branch (only for SVN checkouts, not tarball releases): N/A 
SVN Revision (number only!):  
Request Review:              
====================================================================== 
Date Submitted:             2010-05-07 08:28 CDT
Last Modified:              2010-05-10 23:40 CDT
====================================================================== 
Summary:                    Sequencing numbers of IMAP email messages is
incorrect
Description: 
Left six voicemails which were all successfully delivered to the IMAP
server.  On checking them the sequence numbers were not sequential.  Screen
shot attached.
======================================================================
Relationships       ID      Summary
----------------------------------------------------------------------
related to          0017135 Message count incorrect
child of            0016350 Deleting Multiple IMAP voicemails does ...
====================================================================== 

---------------------------------------------------------------------- 
 (0121682) ebroad (manager) - 2010-05-10 23:40
 https://issues.asterisk.org/view.php?id=17306#c121682 
---------------------------------------------------------------------- 
That logic is correct, strcmp[1] returns 0 when str1 == str2 and
ast_strlen_zero[2] returns 1 when the string is null. So in this case, if
(folder != null) = 0 and strcmp(folder, "INBOX") = 0, !0(which is 1) || 0 =
1, which would evaluate to True. 
With that said, if folder is null, this function could potentially pass a
null value to __messagecount(), i.e. folder == null would be 1, and
!strcmp(folder, "INBOX") would be !1 or -1 which would be 0, meaning we
would still hit  return __messagecount(context, mailbox, "INBOX") +
__messagecount(context, mailbox, "Urgent");. IMHO, I would rewrite it like
this:

static int messagecount(const char *context, const char *mailbox, const
char *folder)
{
    if (!(ast_strlen_zero(folder)) {  
        if (!strcmp(folder, "INBOX")) {
                return __messagecount(context, mailbox, "INBOX") +
__messagecount(context, mailbox, "Urgent");
        } else {
                return __messagecount(context, mailbox, folder);
        }
    } else {
      return -1;
    }
}






[1] http://www.cplusplus.com/reference/clibrary/cstring/strcmp/
[2] http://www.asterisk.org/doxygen/trunk/strings_8h-source.html#l00063 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2010-05-10 23:40 ebroad         Note Added: 0121682                          
======================================================================




More information about the asterisk-bugs mailing list