[asterisk-bugs] [JIRA] (ASTERISK-24786) [patch] - Asterisk terminates when playing a voicemail stored in LDAP

Matt Jordan (JIRA) noreply at issues.asterisk.org
Wed Feb 25 14:35:34 CST 2015


    [ https://issues.asterisk.org/jira/browse/ASTERISK-24786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=225111#comment-225111 ] 

Matt Jordan commented on ASTERISK-24786:
----------------------------------------

I'm not sure it's quite as bad as you might think. The {{RETRIEVE}} macro knows that what is being obtained is a greeting based on the {{msgnum}} passed to it - that is, we know that if we get a {{-1}} in {{imap_retrieve_file}}, that we are going out to get a greeting and that the mailstream will be affected as a result.

After getting a greeting, we need to restore the mailstream back to its prior state. That should be possible, as the previous folder that the state was on should be stored in {{vms->curbox}}. Converting {{vms->curbox}} back to its integer representation for a new call to {{init_mailstream}} can be done using {{get_folder_by_name}}.

That is, after getting a greeting, we should probably have something like:

{code}

int folder_id = get_folder_by_name(vms->curbox);
if (folder_id < 0) {
    folder_id = 0;
}
init_mailstream(vms, folder_id);

{code}

The only other change I would make to your patch is to only call {{init_mailstream}} again if we did play a greeting - otherwise, I think the location you are doing it in is appropriate.

> [patch] - Asterisk terminates when playing a voicemail stored in LDAP
> ---------------------------------------------------------------------
>
>                 Key: ASTERISK-24786
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-24786
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Applications/app_voicemail/IMAP
>    Affects Versions: 13.1.0, 13.2.0
>            Reporter: Graham Barnett
>            Assignee: Matt Jordan
>            Severity: Critical
>         Attachments: app_voicemail.c.patch_terminate
>
>
> Symptom
> # If user has no greetings and user opens mailbox (*97) and tries to play a message, asterisk terminates
> # If user has at least one greeting, playing back a message gives:
> {noformat}
> [14626][C-0000002c]: app_voicemail.c:8677 play_message: No origtime?!
> {noformat}
> Why?
> {code}
> vms_x = get_vm_state_by_imapuser(user, x)
> {code}
> caches existing states by user.
> The states are looked up my imap version, user name, interactive=2 || interactive matches.
> Why does this matter?
> {code}
> int fold = 0;
> vms_p = get_vm_state_by_imapuser(vmu->imapuser, 0);
> if (!vms_p) {
> 		vms_p = get_vm_state_by_mailbox(mailbox, context, 1);
> 	}
> ret = init_mailstream(vms_p, fold);
> {code}
> vs
> {code}
> if (!(vmu = find_user(NULL, context, mailbox))) {
>     RETRIEVE(tempfile, -1, vmu->mailbox, vmu->context);
>     res = imap_retrieve_greeting(dir, msgnum, vmu);
>     if (!(vms_p = get_vm_state_by_mailbox(vmu->mailbox, vmu->context, 1)) && 
>     if (init_mailstream(vms_p, GREETINGS_FOLDER) || !vms_p->mailstream) {
> {code}
> i.e. the mailstream can be left pointed at the GREETINGS and not the Inbox
> And why does that matter?
> {code}
> imap_retrieve_file
> if (!(vms = get_vm_state_by_mailbox(vmu->mailbox, vmu->context, 1)) && !(vms = get_vm_state_by_mailbox(vmu->mailbox, vmu->context, 0))) {
> {code}
> *CAN BE WRONG MAILSTREAM !!!!!*
> {code}
> header_content = mail_fetchheader (vms->mailstream, vms->msgArray[msgnum]);
> {code}
> What is the fix?
> We need to init the mailstream in imap_retrieve_file after getting the vm_state_by_mailbox
> \[Edit: inline patch removed\]
> Will post patch file later.



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list