Skip to content

Commit c849438

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fixed bug #78775
2 parents 2272563 + 3e41ade commit c849438

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

ext/curl/tests/bug78775.phpt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
Bug #78775: TLS issues from HTTP request affecting other encrypted connections
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('curl')) die('skip Requires curl');
6+
if (getenv('SKIP_ONLINE_TESTS')) die('skip Online test');
7+
?>
8+
--FILE--
9+
<?php
10+
11+
$sock = fsockopen("tls://google.com", 443);
12+
13+
var_dump($sock);
14+
15+
$handle = curl_init('https://self-signed.badssl.com/');
16+
curl_setopt_array(
17+
$handle,
18+
[
19+
CURLOPT_RETURNTRANSFER => true,
20+
CURLOPT_SSL_VERIFYPEER => true,
21+
]
22+
);
23+
24+
var_dump(curl_exec($handle));
25+
curl_close($handle);
26+
27+
fwrite($sock, "GET / HTTP/1.0\n\n");
28+
var_dump(fread($sock, 8));
29+
30+
?>
31+
--EXPECTF--
32+
resource(%d) of type (stream)
33+
bool(false)
34+
string(8) "HTTP/1.0"

ext/openssl/xp_ssl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1963,6 +1963,7 @@ static int php_openssl_enable_crypto(php_stream *stream,
19631963
do {
19641964
struct timeval cur_time, elapsed_time;
19651965

1966+
ERR_clear_error();
19661967
if (sslsock->is_client) {
19671968
n = SSL_connect(sslsock->ssl_handle);
19681969
} else {
@@ -2135,6 +2136,7 @@ static ssize_t php_openssl_sockop_io(int read, php_stream *stream, char *buf, si
21352136
}
21362137

21372138
/* Now, do the IO operation. Don't block if we can't complete... */
2139+
ERR_clear_error();
21382140
if (read) {
21392141
nr_bytes = SSL_read(sslsock->ssl_handle, buf, (int)count);
21402142

0 commit comments

Comments
 (0)