File tree Expand file tree Collapse file tree 4 files changed +32
-2
lines changed Expand file tree Collapse file tree 4 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,8 @@ PHP NEWS
84
84
TCP_REUSPORT_LB_CURDOM, TCP_BBR_ALGORITHM constants.
85
85
. socket_create_listen() throws an exception on invalid port value.
86
86
(David Carlier)
87
+ . socket_bind() throws an exception on invalid port value.
88
+ (David Carlier)
87
89
88
90
- Standard:
89
91
. Fixed crypt() tests on musl when using --with-external-libcrypt
Original file line number Diff line number Diff line change @@ -125,8 +125,8 @@ PHP 8.5 UPGRADE NOTES
125
125
last_error to EBADF and raises an E_WARNING message.
126
126
127
127
- Sockets:
128
- . socket_create_listen throws a ValueError if the port is
129
- lower than 0 or greater than 65535.
128
+ . socket_create_listen and socket_bind throw a ValueError
129
+ if the port is lower than 0 or greater than 65535.
130
130
131
131
- Zlib:
132
132
. The "use_include_path" argument for the
Original file line number Diff line number Diff line change @@ -1288,6 +1288,11 @@ PHP_FUNCTION(socket_bind)
1288
1288
php_sock = Z_SOCKET_P (arg1 );
1289
1289
ENSURE_SOCKET_VALID (php_sock );
1290
1290
1291
+ if (port < 0 || port > USHRT_MAX ) {
1292
+ zend_argument_value_error (3 , "must be between 0 and %u" , USHRT_MAX );
1293
+ RETURN_THROWS ();
1294
+ }
1295
+
1291
1296
switch (php_sock -> type ) {
1292
1297
case AF_UNIX :
1293
1298
{
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ socket_bind() with invalid ports.
3
+ --EXTENSIONS--
4
+ sockets
5
+ --FILE--
6
+ <?php
7
+ $ s_c = socket_create (AF_INET , SOCK_STREAM , SOL_TCP );
8
+
9
+ try {
10
+ socket_bind ($ s_c , '0.0.0.0 ' , -1 );
11
+ } catch (\ValueError $ e ) {
12
+ echo $ e ->getMessage () . PHP_EOL ;
13
+ }
14
+
15
+ try {
16
+ socket_bind ($ s_c , '0.0.0.0 ' , 65536 );
17
+ } catch (\ValueError $ e ) {
18
+ echo $ e ->getMessage () . PHP_EOL ;
19
+ }
20
+ ?>
21
+ --EXPECT--
22
+ socket_bind(): Argument #3 ($port) must be between 0 and 65535
23
+ socket_bind(): Argument #3 ($port) must be between 0 and 65535
You can’t perform that action at this time.
0 commit comments