mirror of
https://github.com/php/php-src.git
synced 2024-11-27 03:44:07 +08:00
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix passing non-finite timeout values in stream functions
This commit is contained in:
commit
a0e1e085d8
3
NEWS
3
NEWS
@ -20,6 +20,9 @@ PHP NEWS
|
||||
- Soap:
|
||||
. Fixed bug #55639 (Digest autentication dont work). (nielsdos)
|
||||
|
||||
- Standard:
|
||||
. Fix passing non-finite timeout values in stream functions. (nielsdos)
|
||||
|
||||
- Streams:
|
||||
. Fixed bug GH-15028 (Memory leak in ext/phar/stream.c). (nielsdos)
|
||||
. Fixed bug GH-15034 (Integer overflow on stream_notification_callback
|
||||
|
@ -127,6 +127,9 @@ PHP_FUNCTION(stream_socket_client)
|
||||
|
||||
if (timeout_is_null) {
|
||||
timeout = (double)FG(default_socket_timeout);
|
||||
} else if (!zend_finite(timeout)) {
|
||||
zend_argument_value_error(4, "must be a finite value");
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
context = php_stream_context_from_zval(zcontext, flags & PHP_FILE_NO_DEFAULT_CONTEXT);
|
||||
@ -279,6 +282,9 @@ PHP_FUNCTION(stream_socket_accept)
|
||||
|
||||
if (timeout_is_null) {
|
||||
timeout = (double)FG(default_socket_timeout);
|
||||
} else if (!zend_finite(timeout)) {
|
||||
zend_argument_value_error(2, "must be a finite value");
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
php_stream_from_zval(stream, zstream);
|
||||
|
31
ext/standard/tests/streams/non_finite_values.phpt
Normal file
31
ext/standard/tests/streams/non_finite_values.phpt
Normal file
@ -0,0 +1,31 @@
|
||||
--TEST--
|
||||
Non-finite timeout values in stream functions
|
||||
--FILE--
|
||||
<?php
|
||||
$socket = stream_socket_server("tcp://0.0.0.0:14781", $errno, $errstr);
|
||||
foreach ([NAN, -NAN, INF, -INF] as $value) {
|
||||
try {
|
||||
stream_socket_accept($socket, $value);
|
||||
} catch (ValueError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
}
|
||||
fclose($socket);
|
||||
|
||||
foreach ([NAN, -NAN, INF, -INF] as $value) {
|
||||
try {
|
||||
stream_socket_client("tcp://0.0.0.0:14781", timeout: $value);
|
||||
} catch (ValueError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
stream_socket_accept(): Argument #2 ($timeout) must be a finite value
|
||||
stream_socket_accept(): Argument #2 ($timeout) must be a finite value
|
||||
stream_socket_accept(): Argument #2 ($timeout) must be a finite value
|
||||
stream_socket_accept(): Argument #2 ($timeout) must be a finite value
|
||||
stream_socket_client(): Argument #4 ($timeout) must be a finite value
|
||||
stream_socket_client(): Argument #4 ($timeout) must be a finite value
|
||||
stream_socket_client(): Argument #4 ($timeout) must be a finite value
|
||||
stream_socket_client(): Argument #4 ($timeout) must be a finite value
|
Loading…
Reference in New Issue
Block a user