diff options
author | Tom Sommer <tomsommer@users.noreply.github.com> | 2017-01-14 13:51:12 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2017-01-14 13:53:09 +0100 |
commit | e77a1dbe409aa9f2a2910f1337c8b90786597f69 (patch) | |
tree | 256b4be2d0d2e7f21d4f23bf58aed0b00c82d6e4 | |
parent | 4bf7ef08061720586cb0a2f410720e26719d97f3 (diff) | |
download | php-git-e77a1dbe409aa9f2a2910f1337c8b90786597f69.tar.gz |
Fix bug #69061
Make mail.log append correct PHP_EOL and remove timestamp when
sending to syslog.
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | ext/standard/mail.c | 41 |
2 files changed, 23 insertions, 20 deletions
@@ -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 cce3c7d4ca..26272cd76d 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)) { |