Skip to content

Commit 85657b4

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #62890: default_socket_timeout=-1 causes connection to timeout
2 parents 5d3da2e + eadd980 commit 85657b4

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ PHP NEWS
1414
- Filter:
1515
. Fixed bug #73527 (Invalid memory access in php_filter_strip). (cmb)
1616

17+
- OpenSSL:
18+
. Fixed bug #62890 (default_socket_timeout=-1 causes connection to timeout).
19+
(cmb)
20+
1721
- PDO SQLite:
1822
. Fixed bug #79664 (PDOStatement::getColumnMeta fails on empty result set).
1923
(cmb)

ext/openssl/tests/bug62890.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #62890 (default_socket_timeout=-1 causes connection to timeout)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('openssl')) die('skip openssl extension not available');
6+
if (getenv('SKIP_ONLINE_TESTS')) die('skip online test');
7+
?>
8+
--INI--
9+
default_socket_timeout=-1
10+
--FILE--
11+
<?php
12+
var_dump((bool) file_get_contents('https://php.net'));
13+
?>
14+
--EXPECT--
15+
bool(true)

ext/openssl/xp_ssl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,7 +1956,7 @@ static int php_openssl_enable_crypto(php_stream *stream,
19561956
}
19571957

19581958
timeout = sslsock->is_client ? &sslsock->connect_timeout : &sslsock->s.timeout;
1959-
has_timeout = !sslsock->s.is_blocked && (timeout->tv_sec || timeout->tv_usec);
1959+
has_timeout = !sslsock->s.is_blocked && (timeout->tv_sec > 0 || (timeout->tv_sec == 0 && timeout->tv_usec));
19601960
/* gettimeofday is not monotonic; using it here is not strictly correct */
19611961
if (has_timeout) {
19621962
gettimeofday(&start_time, NULL);
@@ -2108,7 +2108,7 @@ static ssize_t php_openssl_sockop_io(int read, php_stream *stream, char *buf, si
21082108
sslsock->s.is_blocked = 0;
21092109
}
21102110

2111-
if (!sslsock->s.is_blocked && timeout && (timeout->tv_sec || timeout->tv_usec)) {
2111+
if (!sslsock->s.is_blocked && timeout && (timeout->tv_sec > 0 || (timeout->tv_sec == 0 && timeout->tv_usec))) {
21122112
has_timeout = 1;
21132113
/* gettimeofday is not monotonic; using it here is not strictly correct */
21142114
gettimeofday(&start_time, NULL);

0 commit comments

Comments
 (0)