Skip to content

Commit d46665d

Browse files
committed
fix: added 64 bit test
1 parent bce6e73 commit d46665d

2 files changed

Lines changed: 21 additions & 9 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
socket_cmsg_space() rejects a $num larger than INT_MAX on 64-bit platforms
3+
--EXTENSIONS--
4+
sockets
5+
--SKIPIF--
6+
<?php
7+
if (PHP_INT_SIZE < 8) {
8+
die('skip 64-bit only');
9+
}
10+
?>
11+
--FILE--
12+
<?php
13+
// $num is range checked before the level/type pair is looked up
14+
try {
15+
socket_cmsg_space(SOL_SOCKET, 0, PHP_INT_MAX);
16+
} catch (Throwable $e) {
17+
echo $e::class, ': ', $e->getMessage(), "\n";
18+
}
19+
?>
20+
--EXPECT--
21+
ValueError: socket_cmsg_space(): Argument #3 ($num) must be between -2147483648 and 2147483647

ext/sockets/tests/socket_cmsg_space_return_type.phpt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,8 @@ try {
3131
echo $e::class, ': ', $e->getMessage(), "\n";
3232
}
3333

34-
// $num overflows int (64-bit only: PHP_INT_MAX > INT_MAX)
35-
if (PHP_INT_SIZE >= 8) {
36-
try {
37-
socket_cmsg_space(SOL_SOCKET, SCM_RIGHTS, PHP_INT_MAX);
38-
} catch (Throwable $e) {
39-
echo $e::class, ': ', $e->getMessage(), "\n";
40-
}
41-
}
4234
?>
4335
--EXPECT--
4436
string(3) "int"
4537
ValueError: Pair level 999999 and/or type 999999 is not supported
4638
ValueError: socket_cmsg_space(): Argument #3 ($num) must be greater than or equal to 0
47-
ValueError: socket_cmsg_space(): Argument #3 ($num) must be between -2147483648 and 2147483647

0 commit comments

Comments
 (0)