Skip to content

Commit 2af3265

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
2 parents ac67574 + 8537aa6 commit 2af3265

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
@@ -74,6 +74,10 @@ PHP NEWS
7474
. Fixed bug GH-15837 (Segmentation fault in ext/simplexml/simplexml.c).
7575
(nielsdos)
7676

77+
- Sockets:
78+
. Fixed bug GH-16267 (socket_strerror overflow on errno argument).
79+
(David Carlier)
80+
7781
- SOAP:
7882
. Fixed bug #73182 (PHP SOAPClient does not support stream context HTTP
7983
headers in array form). (nielsdos)

ext/sockets/sockets.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,11 @@ PHP_FUNCTION(socket_strerror)
12151215
RETURN_THROWS();
12161216
}
12171217

1218+
if (ZEND_LONG_EXCEEDS_INT(arg1)) {
1219+
zend_argument_value_error(1, "must be between %d and %d", INT_MIN, INT_MAX);
1220+
RETURN_THROWS();
1221+
}
1222+
12181223
RETURN_STRING(sockets_strerror(arg1));
12191224
}
12201225
/* }}} */

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)