[php-src] PR #25503: Reject a $backlog outside of the int range in socket_create_listen() and socket_listen()
| From: | lacatoire | Date: | Mon, 16 Nov 2026 21:49:13 +0000 |
| Subject: | [php-src] PR #25503: Reject a $backlog outside of the int range in socket_create_listen() and socket_listen() | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-40707@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25503
Author: lacatoire
$backlog was narrowed from zend_long to int when passed to
listen(), so 2**32 gave the smallest queue and PHP_INT_MAX a
negative number. Throw a ValueError outside of the int range. -1 is still
accepted.
To reproduce:
```php
<?php
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_bind($socket, '127.0.0.1', 0);
var_dump(socket_listen($socket, 2 ** 32));
var_dump(socket_listen($socket, PHP_INT_MAX));
```
Before (8.5.11): bool(true) twice, the value being truncated silently.
After: ValueError: socket_listen(): Argument #2 ($backlog) must be between -2147483648 and
2147483647
This is a behavior change, so it targets master and has an UPGRADING entry.