Merge branch 'PHP-8.0' into PHP-8.1

This commit is contained in:
Jakub Zelenka 2022-08-07 14:21:27 +01:00
commit c9fa98a174
No known key found for this signature in database
GPG key ID: 1C0779DC5C0A9DE4
4 changed files with 47 additions and 0 deletions

4
NEWS
View file

@ -36,6 +36,10 @@ PHP NEWS
- SQLite3:
. Fixed bug GH-9032 (SQLite3 authorizer crashes on NULL values). (cmb)
- Streams:
. Fixed bug GH-8472 (The resource returned by stream_socket_accept may have
incorrect metadata). (Jakub Zelenka)
04 Aug 2022, PHP 8.1.9
- CLI:

View file

@ -2294,6 +2294,10 @@ static inline int php_openssl_tcp_sockop_accept(php_stream *stream, php_openssl_
memcpy(clisockdata, sock, sizeof(clisockdata->s));
clisockdata->s.socket = clisock;
#ifdef __linux__
/* O_NONBLOCK is not inherited on Linux */
clisockdata->s.is_blocked = 1;
#endif
xparam->outputs.client = php_stream_alloc_rel(stream->ops, clisockdata, NULL, "r+");
if (xparam->outputs.client) {

View file

@ -0,0 +1,35 @@
--TEST--
GH-8472: The resource returned by stream_socket_accept may have incorrect metadata
--FILE--
<?php
function setNonBlocking($stream)
{
$block = stream_get_meta_data($stream)['blocked'];
if ($block) {
stream_set_blocking($stream, false);
}
}
$server = stream_socket_server("tcp://127.0.0.1:9100");
setNonBlocking($server);
$client = stream_socket_client("tcp://127.0.0.1:9100");
$res = stream_socket_accept($server);
stream_set_timeout($res, 1);
setNonBlocking($res);
fwrite($client, str_repeat('0', 5));
$read = [$res];
$write = [];
$except = [];
if (stream_select($read, $write, $except, 1)) {
var_dump(fread($res, 4));
var_dump(fread($res, 4));
}
?>
--EXPECT--
string(4) "0000"
string(1) "0"

View file

@ -841,6 +841,10 @@ static inline int php_tcp_sockop_accept(php_stream *stream, php_netstream_data_t
memcpy(clisockdata, sock, sizeof(*clisockdata));
clisockdata->socket = clisock;
#ifdef __linux__
/* O_NONBLOCK is not inherited on Linux */
clisockdata->is_blocked = 1;
#endif
xparam->outputs.client = php_stream_alloc_rel(stream->ops, clisockdata, NULL, "r+");
if (xparam->outputs.client) {