com php-src: Fix bug #69061: NEWS ext/standard/mail.c

From: Date: Sat, 14 Jan 2017 12:53:09 +0000
Subject: com php-src: Fix bug #69061: NEWS ext/standard/mail.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-96728@lists.php.net to get a copy of this message
Commit: e77a1dbe409aa9f2a2910f1337c8b90786597f69 Author: Tom Sommer <tomsommer@users.noreply.github.com> Sat, 14 Jan 2017 13:51:12 +0100 Committer: Nikita Popov <nikita.ppv@gmail.com> Sat, 14 Jan 2017 13:53:09 +0100 Parents: 4bf7ef08061720586cb0a2f410720e26719d97f3 Branches: PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e77a1dbe409aa9f2a2910f1337c8b90786597f69 Log: Fix bug #69061 Make mail.log append correct PHP_EOL and remove timestamp when sending to syslog. Bugs: https://bugs.php.net/69061 Changed paths: M NEWS M ext/standard/mail.c Diff: diff --git a/NEWS b/NEWS index f1b065d..a9d0bdb 100644 --- a/NEWS +++ b/NEWS @@ -45,6 +45,8 @@ PHP NEWS . Fixed bug #72974 (imap is undefined service on AIX). (matthieu.sarter) . Fixed bug #72979 (money_format stores wrong length AIX). (matthieu.sarter) . Fixed bug #73374 (intval() with base 0 should detect binary). (Leigh) + . Fixed bug #69061 (mail.log = syslog contains double information). + (Tom Sommer) - ZIP: . Fixed bug #70103 (ZipArchive::addGlob ignores remove_all_path option). (cmb, diff --git a/ext/standard/mail.c b/ext/standard/mail.c index cce3c7d...26272cd 100644 --- a/ext/standard/mail.c +++ b/ext/standard/mail.c @@ -286,34 +286,35 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char return val; \ if (mail_log && *mail_log) { - char *tmp; - time_t curtime; - size_t l; - zend_string *date_str; + char *logline; - time(&curtime); - date_str = php_format_date("d-M-Y H:i:s e", 13, curtime, 1); - - l = spprintf(&tmp, 0, "[%s] mail() on [%s:%d]: To: %s -- Headers: %s -- Subject: %s\n", ZSTR_VAL(date_str), zend_get_executed_filename(), zend_get_executed_lineno(), to, hdr ? hdr : "", subject); - - zend_string_free(date_str); + spprintf(&logline, 0, "mail() on [%s:%d]: To: %s -- Headers: %s -- Subject: %s", zend_get_executed_filename(), zend_get_executed_lineno(), to, hdr ? hdr : "", subject); if (hdr) { - php_mail_log_crlf_to_spaces(tmp); + php_mail_log_crlf_to_spaces(logline); } if (!strcmp(mail_log, "syslog")) { - /* Drop the final space when logging to syslog. */ - tmp[l - 1] = 0; - php_mail_log_to_syslog(tmp); - } - else { - /* Convert the final space to a newline when logging to file. */ - tmp[l - 1] = '\n'; - php_mail_log_to_file(mail_log, tmp, l); + php_mail_log_to_syslog(logline); + } else { + /* Add date when logging to file */ + char *tmp; + time_t curtime; + zend_string *date_str; + size_t len; + + + time(&curtime); + date_str = php_format_date("d-M-Y H:i:s e", 13, curtime, 1); + len = spprintf(&tmp, 0, "[%s] %s%s", date_str->val, logline, PHP_EOL); + + php_mail_log_to_file(mail_log, tmp, len); + + zend_string_free(date_str); + efree(tmp); } - efree(tmp); + efree(logline); } if (PG(mail_x_header)) {

« previous php.cvs (#96728) next »