[php-src] PR #25990: Fix GH-25989: Unix socket peer name read from uninitialized memory
| From: | matyapiro31 | Date: | Tue, 01 Dec 2026 05:17:42 +0000 |
| Subject: | [php-src] PR #25990: Fix GH-25989: Unix socket peer name read from uninitialized memory | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-41304@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25990
Author: matyapiro31
Fixes GH-25989.
php_network_populate_name_from_sockaddr() read sun_path of an
AF_UNIX address without regard to the length (sl) returned by the kernel.
For an unnamed peer (a client that never bind()s) sl ==
sizeof(sa_family_t), so sun_path[0] and the subsequent strlen()
read uninitialized stack memory.
This is a code-quality fix, not a security issue: all accesses are reads, and the stale bytes are
PHP's own stack contents that the peer cannot control.
Changes:
- Bound all sun_path accesses by sl; return an empty name when no path was
provided.
- Replace strlen() with a memchr() bounded by the valid length.
- Add a test for the unnamed-client case. Note the bug depends on stack garbage, so the test passes
deterministically after the fix but may also pass before it; it is mainly useful under
Valgrind/MSan.
Testing: main/network.c was syntax-checked with MSVC (cl /Zs); I could not
run the phpt locally (no working full build in my environment), so please rely on CI for that.
🤖 Generated with [Claude Code](https://claude.com/claude-code)