com php-src: fix socket leaking and better connection err check: win32/sendmail.c

From: Date: Tue, 03 Mar 2015 16:19:15 +0000
Subject: com php-src: fix socket leaking and better connection err check: win32/sendmail.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-85180@lists.php.net to get a copy of this message
Commit: 74813e6f047f38ae648bdcf09ac1df838090ae35 Author: Anatol Belski <ab@php.net> Tue, 3 Mar 2015 15:37:08 +0100 Parents: dcb944b35295833d7a90334ccdf08b56a3b707b2 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=74813e6f047f38ae648bdcf09ac1df838090ae35 Log: fix socket leaking and better connection err check Changed paths: M win32/sendmail.c Diff: diff --git a/win32/sendmail.c b/win32/sendmail.c index 9035c7d..194876b 100644 --- a/win32/sendmail.c +++ b/win32/sendmail.c @@ -416,7 +416,11 @@ static int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char /* in the beginning of the dialog */ /* attempt reconnect if the first Post fail */ if ((res = Post(Buffer)) != SUCCESS) { - MailConnect(); + int err = MailConnect(); + if (0 != err) { + return (FAILED_TO_SEND); + } + if ((res = Post(Buffer)) != SUCCESS) { return (res); } @@ -785,12 +789,14 @@ static int MailConnect() /* Get our own host name */ if (gethostname(LocalHost, HOST_NAME_LEN)) { + closesocket(sc); return (FAILED_TO_GET_HOSTNAME); } ent = gethostbyname(LocalHost); if (!ent) { + closesocket(sc); return (FAILED_TO_GET_HOSTNAME); } @@ -803,6 +809,7 @@ static int MailConnect() #endif { if (namelen + 2 >= HOST_NAME_LEN) { + closesocket(sc); return (FAILED_TO_GET_HOSTNAME); } @@ -811,6 +818,7 @@ static int MailConnect() strcpy(LocalHost + namelen + 1, "]"); } else { if (namelen >= HOST_NAME_LEN) { + closesocket(sc); return (FAILED_TO_GET_HOSTNAME); } @@ -836,6 +844,7 @@ static int MailConnect() sock_in.sin_addr.S_un.S_addr = GetAddr(MailHost); if (connect(sc, (LPSOCKADDR) & sock_in, sizeof(sock_in))) { + closesocket(sc); return (FAILED_TO_CONNECT); }

« previous php.cvs (#85180) next »