Skip to content

Commit f12e496

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
2 parents 76a819e + e583890 commit f12e496

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ PHP NEWS
3737
. Fixed bug GH-16385 (Unexpected null returned by session_set_cookie_params).
3838
(nielsdos)
3939

40+
- Sockets:
41+
. Fixed bug with overflow socket_recvfrom $length argument. (David Carlier)
42+
4043
- SPL:
4144
. Fixed bug GH-16337 (Use-after-free in SplHeap). (nielsdos)
4245

ext/sockets/sockets.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,8 @@ PHP_FUNCTION(socket_recvfrom)
14061406

14071407
/* overflow check */
14081408
/* Shouldthrow ? */
1409-
if ((arg3 + 2) < 3) {
1409+
1410+
if (arg3 <= 0 || arg3 > ZEND_LONG_MAX - 1) {
14101411
RETURN_FALSE;
14111412
}
14121413

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
socket_recvfrom overflow on length argument
3+
--EXTENSIONS--
4+
sockets
5+
--SKIPIF--
6+
<?php
7+
if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {
8+
die('skip not valid for Windows.');
9+
}
10+
--FILE--
11+
<?php
12+
$s = socket_create(AF_UNIX, SOCK_DGRAM, 0);
13+
$buf = $end = "";
14+
var_dump(socket_recvfrom($s, $buf, PHP_INT_MAX, 0, $end));
15+
var_dump(socket_recvfrom($s, $buf, -1, 0, $end));
16+
?>
17+
--EXPECT--
18+
bool(false)
19+
bool(false)

0 commit comments

Comments
 (0)