Fix null connection issue introduced in #2060

This commit is contained in:
Marcus Bointon 2020-06-11 17:12:50 +02:00
parent b52fd6e8ad
commit b3650f9f72
No known key found for this signature in database
GPG Key ID: DE31CD6EB646AA24
2 changed files with 20 additions and 10 deletions

View File

@ -1,5 +1,8 @@
# PHPMailer Change Log
## WIP
* Split SMTP connection into two separate methods
## Version 6.1.6 (May 27th, 2020)
* **SECURITY** Fix insufficient output escaping bug in file attachment names. CVE-2020-13625. Reported by Elar Lang of Clarified Security.
* Correct Armenian ISO language code from `am` to `hy`, add mapping for fallback

View File

@ -332,17 +332,13 @@ class SMTP
$this->smtp_conn = $this->getSMTPConnection($host, $port, $timeout, $options);
$this->edebug('Connection: opened', self::DEBUG_CONNECTION);
// SMTP server can take longer to respond, give longer timeout for first read
// Windows does not have support for this timeout function
if (strpos(PHP_OS, 'WIN') !== 0) {
$max = (int) ini_get('max_execution_time');
// Don't bother if unlimited
if (0 !== $max && $timeout > $max) {
@set_time_limit($timeout);
}
stream_set_timeout($this->smtp_conn, $timeout, 0);
if ($this->smtp_conn === false) {
//Error info already set inside `getSMTPConnection()`
return false;
}
$this->edebug('Connection: opened', self::DEBUG_CONNECTION);
// Get any announcement
$announce = $this->get_lines();
$this->edebug('SERVER -> CLIENT: ' . $announce, self::DEBUG_SERVER);
@ -417,6 +413,17 @@ class SMTP
return false;
}
// SMTP server can take longer to respond, give longer timeout for first read
// Windows does not have support for this timeout function
if (strpos(PHP_OS, 'WIN') !== 0) {
$max = (int)ini_get('max_execution_time');
// Don't bother if unlimited
if (0 !== $max && $timeout > $max) {
@set_time_limit($timeout);
}
stream_set_timeout($connection, $timeout, 0);
}
return $connection;
}