summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/openssl/tests/bug62890.phpt15
-rw-r--r--ext/openssl/xp_ssl.c4
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);