[php-src] PR #14483: Fixed off-by-one error in checking length of abstract namespace Unix sockets
| From: | derickr | Date: | Wed, 05 Jun 2024 16:43:32 +0000 |
| Subject: | [php-src] PR #14483: Fixed off-by-one error in checking length of abstract namespace Unix sockets | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-26548@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/14483
Author: derickr
I was trying to use PHP to talk to Xdebug's new out-of-band control sockets, which use the
abstract Unix domain socket namespace (socket names starting with a
\0 character).
Xdebug uses names that are the maximum allowed length for these socket names (108 bytes).
However, when I tried to run:
```
<?php
$name =
"\0xdebug-ctrl.2078073yxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
echo strlen($name), "\n";
$f = stream_socket_client("unix://$name");
```
I got the following output and error:
```
108
Notice: stream_socket_client(): socket path exceeded the maximum allowed length of 108 bytes and was
truncated in Standard input code on line 2
```
But the path is exactly 108 characters, not *more*. It turned out that the check for this maximum
length is wrong.
No new test can easily be created, as the 108 is implementation specific, and
ext/standard/tests/streams/bug60106.phpt already covers it.
With this change, I can now correctly connection to these sockets.