Skip to content

Commit 062b3ca

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
2 parents d1a313e + 2af3265 commit 062b3ca

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ PHP NEWS
163163
. Fixed bug GH-15837 (Segmentation fault in ext/simplexml/simplexml.c).
164164
(nielsdos)
165165

166+
- Sockets:
167+
. Fixed bug GH-16267 (socket_strerror overflow on errno argument).
168+
(David Carlier)
169+
166170
- SOAP:
167171
. Fixed bug #73182 (PHP SOAPClient does not support stream context HTTP
168172
headers in array form). (nielsdos)

ext/sockets/sockets.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,11 @@ 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);
1253+
RETURN_THROWS();
1254+
}
1255+
12511256
RETURN_STRING(sockets_strerror(arg1));
12521257
}
12531258
/* }}} */

ext/sockets/tests/gh16267.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
GH-16267 - overflow on socket_strerror argument
3+
--EXTENSIONS--
4+
sockets
5+
--SKIPIF--
6+
<?php if (PHP_INT_SIZE != 8) die('skip 64-bit only'); ?>
7+
--FILE--
8+
<?php
9+
try {
10+
socket_strerror(PHP_INT_MIN);
11+
} catch (\ValueError $e) {
12+
echo $e->getMessage() . PHP_EOL;
13+
}
14+
try {
15+
socket_strerror(PHP_INT_MAX);
16+
} catch (\ValueError $e) {
17+
echo $e->getMessage() . PHP_EOL;
18+
}
19+
?>
20+
--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

0 commit comments

Comments
 (0)