File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ PHP NEWS
2020- Soap:
2121 . Fixed bug #55639 (Digest autentication dont work). (nielsdos)
2222
23+ - Standard:
24+ . Fix passing non-finite timeout values in stream functions. (nielsdos)
25+
2326- Streams:
2427 . Fixed bug GH-15028 (Memory leak in ext/phar/stream.c). (nielsdos)
2528 . Fixed bug GH-15034 (Integer overflow on stream_notification_callback
Original file line number Diff line number Diff line change @@ -127,6 +127,9 @@ PHP_FUNCTION(stream_socket_client)
127127
128128 if (timeout_is_null ) {
129129 timeout = (double )FG (default_socket_timeout );
130+ } else if (!zend_finite (timeout )) {
131+ zend_argument_value_error (4 , "must be a finite value" );
132+ RETURN_THROWS ();
130133 }
131134
132135 context = php_stream_context_from_zval (zcontext , flags & PHP_FILE_NO_DEFAULT_CONTEXT );
@@ -279,6 +282,9 @@ PHP_FUNCTION(stream_socket_accept)
279282
280283 if (timeout_is_null ) {
281284 timeout = (double )FG (default_socket_timeout );
285+ } else if (!zend_finite (timeout )) {
286+ zend_argument_value_error (2 , "must be a finite value" );
287+ RETURN_THROWS ();
282288 }
283289
284290 php_stream_from_zval (stream , zstream );
Original file line number Diff line number Diff line change 1+ --TEST--
2+ Non-finite timeout values in stream functions
3+ --FILE--
4+ <?php
5+ $ socket = stream_socket_server ("tcp://0.0.0.0:14781 " , $ errno , $ errstr );
6+ foreach ([NAN , -NAN , INF , -INF ] as $ value ) {
7+ try {
8+ stream_socket_accept ($ socket , $ value );
9+ } catch (ValueError $ e ) {
10+ echo $ e ->getMessage (), "\n" ;
11+ }
12+ }
13+ fclose ($ socket );
14+
15+ foreach ([NAN , -NAN , INF , -INF ] as $ value ) {
16+ try {
17+ stream_socket_client ("tcp://0.0.0.0:14781 " , timeout: $ value );
18+ } catch (ValueError $ e ) {
19+ echo $ e ->getMessage (), "\n" ;
20+ }
21+ }
22+ ?>
23+ --EXPECT--
24+ stream_socket_accept(): Argument #2 ($timeout) must be a finite value
25+ stream_socket_accept(): Argument #2 ($timeout) must be a finite value
26+ stream_socket_accept(): Argument #2 ($timeout) must be a finite value
27+ stream_socket_accept(): Argument #2 ($timeout) must be a finite value
28+ stream_socket_client(): Argument #4 ($timeout) must be a finite value
29+ stream_socket_client(): Argument #4 ($timeout) must be a finite value
30+ stream_socket_client(): Argument #4 ($timeout) must be a finite value
31+ stream_socket_client(): Argument #4 ($timeout) must be a finite value
You can’t perform that action at this time.
0 commit comments