Skip to content

Commit b51c2cd

Browse files
committed
win32/sendmail.c/MailConnect(): pass host as param
This removes the usage of a global
1 parent 708144b commit b51c2cd

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

win32/php_win32_globals.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ struct _php_win32_core_globals {
4242

4343
char mail_buffer[MAIL_BUFFER_SIZE];
4444
SOCKET mail_socket;
45-
char mail_host[HOST_NAME_LEN];
4645
char mail_local_host[HOST_NAME_LEN];
4746
};
4847

win32/sendmail.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ static const char *ErrorMessages[] =
114114

115115
static int SendText(_In_ const char *host, const char *RPath, const char *Subject, const char *mailTo, const char *data,
116116
zend_string *headers, zend_string *headers_lc, char **error_message);
117-
static int MailConnect();
117+
static int MailConnect(_In_ const char *host);
118118
static bool PostHeader(const char *RPath, const char *Subject, const char *mailTo, zend_string *xheaders);
119119
static bool Post(LPCSTR msg);
120120
static int Ack(char **server_response);
@@ -391,15 +391,8 @@ static int SendText(_In_ const char *host, const char *RPath, const char *Subjec
391391
return (BAD_MSG_DESTINATION);
392392
*/
393393

394-
if (strlen(host) >= HOST_NAME_LEN) {
395-
*error = BAD_MAIL_HOST;
396-
return FAILURE;
397-
} else {
398-
strcpy(PW32G(mail_host), host);
399-
}
400-
401394
/* attempt to connect with mail host */
402-
res = MailConnect();
395+
res = MailConnect(host);
403396
if (res != 0) {
404397
/* 128 is safe here, the specifier in snprintf isn't longer than that */
405398
*error_message = ecalloc(1, HOST_NAME_LEN + 128);
@@ -708,7 +701,7 @@ static bool PostHeader(const char *RPath, const char *Subject, const char *mailT
708701
// Author/Date: jcar 20/9/96
709702
// History:
710703
//*********************************************************************
711-
static int MailConnect()
704+
static int MailConnect(_In_ const char *host)
712705
{
713706

714707
int res, namelen;
@@ -764,7 +757,7 @@ return 0;
764757
}
765758

766759
/* Resolve the servers IP */
767-
unsigned long server_addr = GetAddr(PW32G(mail_host));
760+
unsigned long server_addr = GetAddr(host);
768761

769762
portnum = (short) INI_INT("smtp_port");
770763
if (!portnum) {

0 commit comments

Comments
 (0)