summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-06-09 16:46:32 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2020-06-09 16:47:00 +0200
commit85657b486f863368dd891410d59d6c1878b753ae (patch)
tree57ca4f34472032ec59c35f6fb5491b526ae3c385
parent5d3da2e74811ac44bc734bd13b5d6e29afbb7bc0 (diff)
parenteadd98070662f0c56d7138bcb2a42d397c11f6e4 (diff)
downloadphp-git-85657b486f863368dd891410d59d6c1878b753ae.tar.gz
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #62890: default_socket_timeout=-1 causes connection to timeout
-rw-r--r--NEWS4
-rw-r--r--ext/openssl/tests/bug62890.phpt15
-rw-r--r--ext/openssl/xp_ssl.c4
3 files changed, 21 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 472577937b..13ae3f80c6 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,10 @@ PHP NEWS
- Filter:
. Fixed bug #73527 (Invalid memory access in php_filter_strip). (cmb)
+- OpenSSL:
+ . Fixed bug #62890 (default_socket_timeout=-1 causes connection to timeout).
+ (cmb)
+
- PDO SQLite:
. Fixed bug #79664 (PDOStatement::getColumnMeta fails on empty result set).
(cmb)
diff --git a/ext/openssl/tests/bug62890.phpt b/ext/openssl/tests/bug62890.phpt
new file mode 100644
index 0000000000..b400b0e5ef
--- /dev/null
+++ b/ext/openssl/tests/bug62890.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #62890 (default_socket_timeout=-1 causes connection to timeout)
+--SKIPIF--
+<?php
+if (!extension_loaded('openssl')) die('skip openssl extension not available');
+if (getenv('SKIP_ONLINE_TESTS')) die('skip online test');
+?>
+--INI--
+default_socket_timeout=-1
+--FILE--
+<?php
+var_dump((bool) file_get_contents('https://php.net'));
+?>
+--EXPECT--
+bool(true)
diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c
index c6e9a29b45..31f8ffa424 100644
--- a/ext/openssl/xp_ssl.c
+++ b/ext/openssl/xp_ssl.c
@@ -1956,7 +1956,7 @@ static int php_openssl_enable_crypto(php_stream *stream,
}
timeout = sslsock->is_client ? &sslsock->connect_timeout : &sslsock->s.timeout;
- has_timeout = !sslsock->s.is_blocked && (timeout->tv_sec || timeout->tv_usec);
+ has_timeout = !sslsock->s.is_blocked && (timeout->tv_sec > 0 || (timeout->tv_sec == 0 && timeout->tv_usec));
/* gettimeofday is not monotonic; using it here is not strictly correct */
if (has_timeout) {
gettimeofday(&start_time, NULL);
@@ -2108,7 +2108,7 @@ static ssize_t php_openssl_sockop_io(int read, php_stream *stream, char *buf, si
sslsock->s.is_blocked = 0;
}
- if (!sslsock->s.is_blocked && timeout && (timeout->tv_sec || timeout->tv_usec)) {
+ if (!sslsock->s.is_blocked && timeout && (timeout->tv_sec > 0 || (timeout->tv_sec == 0 && timeout->tv_usec))) {
has_timeout = 1;
/* gettimeofday is not monotonic; using it here is not strictly correct */
gettimeofday(&start_time, NULL);