SMTP_PORT should pass to htons()
Robert Young <[email protected]>
| Newsgroups | gmane.comp.gnu.mailutils.bugs |
|---|---|
| Message-ID | <CAJjz_NiUE5SY1H1H_aLHqTrWbqiJ0-9mgQYNGpTJ0nOvsftrHA@mail.gmail.com> |
ERROR: connect to wrong port when smtp_port specified tmp # date | /usr/bin/mail --debug-level=mailer.prot --exec='set sendmail=smtps://your_mail:[email protected]:465' --append='From: Test <[email protected]>' --subject=Test [email protected] mail: Cannot open mailer: Connection timed out mail: cannot send message: Connection timed out tmp # tmp # netstat -natp | grep /mail tcp 0 1 192.168.1.113:12863 74.125.204.109:53505 SYN_SENT 31829/mail tmp # PATCH to solve this issue: --- mailutils-3.3/libmailutils/sockaddr/fromnode.c 2017-06-08 13:08:20.000000000 +0000 +++ mailutils-3.3/libmailutils/sockaddr/fromnode.c 2017-10-20 00:57:02.928152699 +0000 @@ -30,6 +30,7 @@ #include <stdio.h> #include <errno.h> #include <string.h> +#include <limits.h> #include <mailutils/sockaddr.h> #include <mailutils/url.h> #include <mailutils/io.h> @@ -194,8 +195,10 @@ return MU_ERR_SERVICE; port = sp->s_port; } - else if (n == 0 || (port = n) != n) - return MU_ERR_PARSE; /* FIXME: need MU_ERR_RANGE? */ + else if (n == 0 || n > USHRT_MAX) + return ERANGE; + else + port = htons (n); } else if (mh->port) port = htons (mh->port); PATCHED_TESTS: TEST1 PORT==0 : tmp # date | /usr/bin/mail --debug-level=mailer.prot --exec='set sendmail=smtps://your_mail:[email protected]:0' --append='From: Test <[email protected]>' --subject=Test [email protected] mail: Cannot open mailer: Numerical result out of range mail: cannot send message: Numerical result out of range TEST2 PORT==65536 : tmp # date | /usr/bin/mail --debug-level=mailer.prot --exec='set sendmail=smtps://your_mail:[email protected]:655 36' --append='From: Test <[email protected]>' --subject=Test [email protected] mail: Cannot create mailer: Numerical result out of range mail: cannot send message: Numerical result out of range TEST3 PORT=="bad" : tmp # date | /usr/bin/mail --debug-level=mailer.prot --exec='set sendmail=smtps://your_mail:[email protected]:bad ' --append='From: Test <[email protected]>' --subject=Test [email protected] mail: Cannot create mailer: Invalid port or service specification mail: cannot send message: Invalid port or service specification TEST4 PORT=="smtps" : tmp # date | /usr/bin/mail --debug-level=mailer.prot --exec='set sendmail=smtps://your_mail:[email protected]:smt ps' --append='From: Test <[email protected]>' --subject=Test [email protected] mail: S: 220 smtp.gmail.com ESMTP t9sm27356803pgr.3 - gsmtp ... mail: S: 250 2.0.0 OK 1508461891 t9sm27356803pgr.3 - gsmtp mail: C: QUIT mail: S: 221 2.0.0 closing connection t9sm27356803pgr.3 - gsmtp TEST5 PORT==465 : tmp # date | /usr/bin/mail --debug-level=mailer.prot --exec='set sendmail=smtps://your_mail:[email protected]:465 ' --append='From: Test <[email protected]>' --subject=Test [email protected] mail: S: 220 smtp.gmail.com ESMTP g24sm29902885pfk.0 - gsmtp mail: C: QUIT mail: S: 250 2.0.0 OK 1508461944 g24sm29902885pfk.0 - gsmtp mail: S: 221 2.0.0 closing connection g24sm29902885pfk.0 - gsmtp