summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2017-02-01 12:57:02 +0100
committerAnatol Belski <ab@php.net>2017-02-01 12:57:02 +0100
commit5a7fe51235f3f599a87f7f4e4eaad71bf8f8808c (patch)
tree12f6924c51e40127d89afda553b927617b22f9cb
parentcd5d6efaf083288c414a9e9e989bd06aa463906d (diff)
parent15404bda138ec073dec382ad71472f461305921b (diff)
downloadphp-git-5a7fe51235f3f599a87f7f4e4eaad71bf8f8808c.tar.gz
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0: remove unused var use zend_string API Fixed bug #74005 mail.add_x_header causes RFC-breaking lone line feed
-rw-r--r--win32/sendmail.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/win32/sendmail.c b/win32/sendmail.c
index bdeff314a0..28befc3f96 100644
--- a/win32/sendmail.c
+++ b/win32/sendmail.c
@@ -173,7 +173,7 @@ static zend_string *php_win32_mail_trim_header(char *header)
regex = zend_string_init(PHP_WIN32_MAIL_RMVDBL_PATTERN, sizeof(PHP_WIN32_MAIL_RMVDBL_PATTERN)-1, 0);
result2 = php_pcre_replace(regex,
- result, result->val, (int)result->len,
+ result, ZSTR_VAL(result), (int)ZSTR_LEN(result),
&replace,
0,
-1,
@@ -208,7 +208,7 @@ PHPAPI int TSendMail(char *host, int *error, char **error_message,
{
int ret;
char *RPath = NULL;
- zend_string *headers_lc = NULL; /* headers_lc is only created if we've a header at all */
+ zend_string *headers_lc = NULL, *headers_trim = NULL; /* headers_lc is only created if we've a header at all */
char *pos1 = NULL, *pos2 = NULL;
if (host == NULL) {
@@ -223,19 +223,16 @@ PHPAPI int TSendMail(char *host, int *error, char **error_message,
if (headers) {
char *pos = NULL;
- size_t i;
/* Use PCRE to trim the header into the right format */
- if (NULL == (headers_lc = php_win32_mail_trim_header(headers))) {
+ if (NULL == (headers_trim = php_win32_mail_trim_header(headers))) {
*error = W32_SM_PCRE_ERROR;
return FAILURE;
}
/* Create a lowercased header for all the searches so we're finally case
* insensitive when searching for a pattern. */
- for (i = 0; i < headers_lc->len; i++) {
- headers_lc->val[i] = tolower(headers_lc->val[i]);
- }
+ headers_lc = zend_string_tolower(headers_trim);
}
/* Fall back to sendmail_from php.ini setting */
@@ -245,14 +242,14 @@ PHPAPI int TSendMail(char *host, int *error, char **error_message,
RPath = estrdup(INI_STR("sendmail_from"));
} else if (headers_lc) {
int found = 0;
- char *lookup = headers_lc->val;
+ char *lookup = ZSTR_VAL(headers_lc);
while (lookup) {
pos1 = strstr(lookup, "from:");
if (!pos1) {
break;
- } else if (pos1 != headers_lc->val && *(pos1-1) != '\n') {
+ } else if (pos1 != ZSTR_VAL(headers_lc) && *(pos1-1) != '\n') {
if (strlen(pos1) >= sizeof("from:")) {
lookup = pos1 + sizeof("from:");
continue;
@@ -292,6 +289,7 @@ PHPAPI int TSendMail(char *host, int *error, char **error_message,
efree(RPath);
}
if (headers) {
+ zend_string_free(headers_trim);
zend_string_free(headers_lc);
}
/* 128 is safe here, the specifier in snprintf isn't longer than that */
@@ -304,12 +302,13 @@ PHPAPI int TSendMail(char *host, int *error, char **error_message,
PW32G(mail_host), !INI_INT("smtp_port") ? 25 : INI_INT("smtp_port"));
return FAILURE;
} else {
- ret = SendText(RPath, Subject, mailTo, mailCc, mailBcc, data, headers, headers_lc->val, error_message);
+ ret = SendText(RPath, Subject, mailTo, mailCc, mailBcc, data, ZSTR_VAL(headers_trim), ZSTR_VAL(headers_lc), error_message);
TSMClose();
if (RPath) {
efree(RPath);
}
if (headers) {
+ zend_string_free(headers_trim);
zend_string_free(headers_lc);
}
if (ret != SUCCESS) {
@@ -635,8 +634,8 @@ static int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char
/* send message contents in 1024 chunks */
{
- char c, *e2, *e = data_cln->val + data_cln->len;
- p = data_cln->val;
+ char c, *e2, *e = ZSTR_VAL(data_cln) + ZSTR_LEN(data_cln);
+ p = ZSTR_VAL(data_cln);
while (e - p > 1024) {
e2 = p + 1024;
@@ -713,7 +712,7 @@ static int PostHeader(char *RPath, char *Subject, char *mailTo, char *xheaders)
time_t tNow = time(NULL);
zend_string *dt = php_format_date("r", 1, tNow, 1);
- snprintf(header_buffer, MAIL_BUFFER_SIZE, "Date: %s\r\n", dt->val);
+ snprintf(header_buffer, MAIL_BUFFER_SIZE, "Date: %s\r\n", ZSTR_VAL(dt));
zend_string_free(dt);
}