com php-src: Fix #77821: Potential heap corruption in TSendMail(): win32/sendmail.c

From: Date: Tue, 30 Apr 2019 05:08:19 +0000
Subject: com php-src: Fix #77821: Potential heap corruption in TSendMail(): win32/sendmail.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-105985@lists.php.net to get a copy of this message
Commit: 6c631ccfef94f93259d474682f8bfa803e163c87 Author: Christoph M. Becker <cmbecker69@gmx.de> Fri, 29 Mar 2019 11:12:09 +0100 Committer: Stanislav Malyshev <stas@php.net> Mon, 29 Apr 2019 22:08:19 -0700 Parents: 588db7cecf6cf8b351de0fecdfc7de70f54bf1b1 Branches: PHP-7.1 PHP-7.2 PHP-7.3 PHP-7.4 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=6c631ccfef94f93259d474682f8bfa803e163c87 Log: Fix #77821: Potential heap corruption in TSendMail() zend_string_tolower() returns a copy (not a duplicate) of the given string, if it is already in lower case. In this case we must not not zend_string_free() both strings. The cleanest solution is to call zend_string_release() on both strings, which properly handles the refcount. Bugs: https://bugs.php.net/77821 Changed paths: M win32/sendmail.c Diff: diff --git a/win32/sendmail.c b/win32/sendmail.c index 808fc8f..c11da78 100644 --- a/win32/sendmail.c +++ b/win32/sendmail.c @@ -274,8 +274,9 @@ PHPAPI int TSendMail(char *host, int *error, char **error_message, } if (!found) { - if (headers_lc) { - zend_string_free(headers_lc); + if (headers) { + zend_string_release(headers_trim); + zend_string_release(headers_lc); } *error = W32_SM_SENDMAIL_FROM_NOT_SET; return FAILURE; @@ -289,8 +290,8 @@ PHPAPI int TSendMail(char *host, int *error, char **error_message, efree(RPath); } if (headers) { - zend_string_free(headers_trim); - zend_string_free(headers_lc); + zend_string_release(headers_trim); + zend_string_release(headers_lc); } /* 128 is safe here, the specifier in snprintf isn't longer than that */ if (NULL == (*error_message = ecalloc(1, HOST_NAME_LEN + 128))) { @@ -308,8 +309,8 @@ PHPAPI int TSendMail(char *host, int *error, char **error_message, efree(RPath); } if (headers) { - zend_string_free(headers_trim); - zend_string_free(headers_lc); + zend_string_release(headers_trim); + zend_string_release(headers_lc); } if (ret != SUCCESS) { *error = ret;

« previous php.cvs (#105985) next »