Skip to content

Commit c82e151

Browse files
committed
ext/sockets: socket_strerror follow-up on GH-16267 fix.
boundaries should be INT_MIN <= val < INT_MAX in fact.
1 parent 7b9b832 commit c82e151

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

ext/sockets/sockets.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,8 +1248,8 @@ PHP_FUNCTION(socket_strerror)
12481248
Z_PARAM_LONG(arg1)
12491249
ZEND_PARSE_PARAMETERS_END();
12501250

1251-
if (ZEND_LONG_EXCEEDS_INT(arg1)) {
1252-
zend_argument_value_error(1, "must be between %d and %d", INT_MIN, INT_MAX);
1251+
if (arg1 <= INT_MIN || arg1 > INT_MAX) {
1252+
zend_argument_value_error(1, "must be greater than %d and lower than %d", INT_MIN, INT_MAX);
12531253
RETURN_THROWS();
12541254
}
12551255

ext/sockets/tests/gh16267.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ sockets
77
--FILE--
88
<?php
99
try {
10-
socket_strerror(PHP_INT_MIN);
10+
socket_strerror(-2147483648);
1111
} catch (\ValueError $e) {
1212
echo $e->getMessage() . PHP_EOL;
1313
}
1414
try {
15-
socket_strerror(PHP_INT_MAX);
15+
socket_strerror(2147483648);
1616
} catch (\ValueError $e) {
1717
echo $e->getMessage() . PHP_EOL;
1818
}
1919
?>
2020
--EXPECTF--
21-
socket_strerror(): Argument #1 ($error_code) must be between %s and %s
22-
socket_strerror(): Argument #1 ($error_code) must be between %s and %s
21+
socket_strerror(): Argument #1 ($error_code) must be greater than %s and lower than %s
22+
socket_strerror(): Argument #1 ($error_code) must be greater than %s and lower than %s

0 commit comments

Comments
 (0)