php-src/ext/sockets/tests/socket_recv_overflow.phpt
David Carlier e583890af0
Fix socket_recvfrom overflow on buffer size.
when passing PHP_INT_MAX for the $length param we get this (with ubsan)

`ext/sockets/sockets.c:1409:36: runtime error: signed integer overflow: 9223372036854775807 + 1 cannot be represented in type 'long int'`

close GH-16382
2024-10-12 15:23:03 +01:00

20 lines
409 B
PHP

--TEST--
socket_recvfrom overflow on length argument
--EXTENSIONS--
sockets
--SKIPIF--
<?php
if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {
die('skip not valid for Windows.');
}
--FILE--
<?php
$s = socket_create(AF_UNIX, SOCK_DGRAM, 0);
$buf = $end = "";
var_dump(socket_recvfrom($s, $buf, PHP_INT_MAX, 0, $end));
var_dump(socket_recvfrom($s, $buf, -1, 0, $end));
?>
--EXPECT--
bool(false)
bool(false)