diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-06-09 16:48:41 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-06-09 16:48:41 +0200 |
commit | 4b76a2ddb350b316153437fcae2efabbc37147f6 (patch) | |
tree | 8ece78958a77ef3889239fa2711f21de582e3eaa | |
parent | 3b8d26accf1c0613614a2091314fd6af9fc9ac21 (diff) | |
parent | 85657b486f863368dd891410d59d6c1878b753ae (diff) | |
download | php-git-4b76a2ddb350b316153437fcae2efabbc37147f6.tar.gz |
Merge branch 'PHP-7.4'
* PHP-7.4:
Fix #62890: default_socket_timeout=-1 causes connection to timeout
-rw-r--r-- | ext/openssl/tests/bug62890.phpt | 15 | ||||
-rw-r--r-- | ext/openssl/xp_ssl.c | 4 |
2 files changed, 17 insertions, 2 deletions
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 0ace22af85..7b28d79f0a 100644 --- a/ext/openssl/xp_ssl.c +++ b/ext/openssl/xp_ssl.c @@ -1910,7 +1910,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); @@ -2044,7 +2044,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); |