Re: mail_open gives an invalid handle to a MAILSTREAM

Alejandro RĂ­os <[email protected]> Wed, 28 May 2014 16:56:21 -0500
Newsgroups gmane.mail.imap.uw.c-client
Message-ID <CAM16xaHVsMpo4oABtQgORoPrU5YU1pjXdmEdQsdd9qzHgPWkCg@mail.gmail.com>
--===============3911385099671437551==
Content-Type: multipart/alternative; boundary=047d7bacbb480344f104fa7ce27a

--047d7bacbb480344f104fa7ce27a
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hi Eduardo, thanks for checking,

I increased the size of the variable in get_mailbox_delimiter to: "char
tmp[256]"  with the same results.

I also added a debug line to show the value of vms inside init_mailstream:
...
/* Now connect to the target folder */
        imap_mailbox_name(tmp, sizeof(tmp), vms, box, 1);
        ast_debug(3, "Before mail_open, server: %s, box:%d\n", tmp, box);
        ast_debug(3, "Value of vms at init_mailstream %s\n", vms);
        ast_mutex_lock(&vms->lock);
        vms->mailstream =3D mail_open (stream, tmp, debug ? OP_DEBUG : NIL)=
;
...

And it shows the value: INBOX

May 28 17:48:32 vdc400 asterisk[14250]: DEBUG[17595][C-00000000]:
app_voicemail.c:2952 in init_mailstream: Value of vms at init_mailstream
INBOX

Not sure if that is what you where asking to show.


Thanks again,

Alejandro





2014-05-28 1:49 GMT-05:00 Eduardo Chappa <[email protected]>:

> On Tue, 27 May 2014, Alejandro R=C3=ADos wrote:
>
>                  get_mailbox_delimiter(vms, stream);
>>
>
> Does the tmp variable in the function above have enough space to hold the
> server specification? it seems that it does not (a char tmp[50] declarati=
on
> seems too small, and then you do a sprintf on it...), so it looks like yo=
u
> are corrupting the stack.
>
> If this is not the case, can you show the value of *vms? in the function
> init_mailstream?
>
> --
> Eduardo
> http://patches.freeiz.com/alpine/
>

--047d7bacbb480344f104fa7ce27a
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div>Hi Eduardo, thanks for checking,<br><br></div>I =
increased the size of the variable in get_mailbox_delimiter to: &quot;char =
tmp[256]&quot;=C2=A0 with the same results.<br><br></div>I also added a deb=
ug line to show the value of vms inside init_mailstream:<br>
...<br>/* Now connect to the target folder */<br>=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0 imap_mailbox_name(tmp, sizeof(tmp), vms, box, 1);<br>=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ast_debug(3, &quot;Before mail_open=
, server: %s, box:%d\n&quot;, tmp, box);<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 ast_debug(3, &quot;Value of vms at init_mailstream %s\n&quot;,=
 vms);<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ast_mutex_lock(&amp;vms-&gt;lock=
);<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 vms-&gt;mailstream =3D mai=
l_open (stream, tmp, debug ? OP_DEBUG : NIL);<br>...<br><div><br></div><div=
>And it shows the value: INBOX<br></div><div><br>May 28 17:48:32 vdc400 ast=
erisk[14250]: DEBUG[17595][C-00000000]: app_voicemail.c:2952 in init_mailst=
ream: Value of vms at init_mailstream INBOX<br>
<br></div><div>Not sure if that is what you where asking to show.<br><br><b=
r></div><div>Thanks again,<br><br></div><div>Alejandro<br></div><div><br><b=
r></div><div><br></div></div><div class=3D"gmail_extra"><br><br><div class=
=3D"gmail_quote">
2014-05-28 1:49 GMT-05:00 Eduardo Chappa <span dir=3D"ltr">&lt;<a href=3D"m=
ailto:[email protected]" target=3D"_blank">[email protected]</a>&gt;</span>:<br=
><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1=
px #ccc solid;padding-left:1ex">
On Tue, 27 May 2014, Alejandro R=C3=ADos wrote:<br>
<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 get_mailbox_delimiter(vms, stream);<br>
</blockquote>
<br>
Does the tmp variable in the function above have enough space to hold the s=
erver specification? it seems that it does not (a char tmp[50] declaration =
seems too small, and then you do a sprintf on it...), so it looks like you =
are corrupting the stack.<br>

<br>
If this is not the case, can you show the value of *vms? in the function<br=
>
init_mailstream?<span class=3D"HOEnZb"><font color=3D"#888888"><br>
<br>
-- <br>
Eduardo<br>
<a href=3D"http://patches.freeiz.com/alpine/" target=3D"_blank">http://patc=
hes.freeiz.com/<u></u>alpine/</a><br>
</font></span></blockquote></div><br></div>

--047d7bacbb480344f104fa7ce27a--

--===============3911385099671437551==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Imap-uw mailing list
[email protected]
http://mailman13.u.washington.edu/mailman/listinfo/imap-uw

--===============3911385099671437551==--