[ libetpan-Bugs-1464347 ] bug when using mailimap_socket_connect with port==0

"SourceForge.net" <[email protected]> Tue, 04 Apr 2006 12:57:41 -0700
Newsgroups gmane.mail.libetpan.user
Message-ID <[email protected]>
Bugs item #1464347, was opened at 2006-04-04 16:42
Message generated for change (Comment added) made by hoa
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=429696&aid=1464347&group_id=41064

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: IMAP4
Group: Latest development - libEtPan!
Status: Open
Resolution: None
Priority: 5
Submitted By: Michael Leupold (lemma)
Assigned to: Nobody/Anonymous (nobody)
Summary: bug when using mailimap_socket_connect with port==0

Initial Comment:
I found the following bug in
libetpan/src/low-level/imap/mailimap_socket.c:
When connecting using mailimap_socket_connect, the
connection may fail if port == 0 and getservbyname
can't resolve the service (mostly windows where "imap2"
is known as "imap", you can reproduce this on linux by
commenting imap2 in /etc/services).

line 57:
if (port == 0) {
  port = mail_get_service_port(SERVICE_NAME_IMAP,
SERVICE_TYPE_TCP);
  if (port == 0)
    port = DEFAULT_IMAP_PORT;
  port = ntohs(port);
}

port is assigned 143 (host-byte-order) which is then
assumed to be in nbo and converted to hbo.
I believe this should be fixed by replacing line 61 and
inserting:
else
  port = ntohs(port);
which converts only ports returned by getservbyname to
host-byte-order.
I tested it on debian pure64 and windows xp and it
worked for both, so I attached a patch vs current cvs
(cvs diff -u -r1.12).

Kind regards,
Michael

----------------------------------------------------------------------

>Comment By: DINH V. Hoa (hoa)
Date: 2006-04-04 19:57

Message:
Logged In: YES 
user_id=201468

thanks, I'll rather fix mail_get_service_port()
to return something in host bytes order.
I am waiting for sourceforge CVS to be up again to commit it.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=429696&aid=1464347&group_id=41064


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642