File tree 3 files changed +40
-0
lines changed 3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ PHP NEWS
20
20
- Soap:
21
21
. Fixed bug #55639 (Digest autentication dont work). (nielsdos)
22
22
23
+ - Standard:
24
+ . Fix passing non-finite timeout values in stream functions. (nielsdos)
25
+
23
26
- Streams:
24
27
. Fixed bug GH-15028 (Memory leak in ext/phar/stream.c). (nielsdos)
25
28
. 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)
127
127
128
128
if (timeout_is_null ) {
129
129
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 ();
130
133
}
131
134
132
135
context = php_stream_context_from_zval (zcontext , flags & PHP_FILE_NO_DEFAULT_CONTEXT );
@@ -279,6 +282,9 @@ PHP_FUNCTION(stream_socket_accept)
279
282
280
283
if (timeout_is_null ) {
281
284
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 ();
282
288
}
283
289
284
290
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