[php-src] PR #22426: Fix posix_getpwnam()/posix_getpwuid() crash on NULL passwd fields
| From: | iliaal | Date: | Wed, 24 Jun 2026 11:22:13 +0000 |
| Subject: | [php-src] PR #22426: Fix posix_getpwnam()/posix_getpwuid() crash on NULL passwd fields | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36592@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22426
Author: iliaal
php_posix_passwd_to_array() passed pw_name, pw_passwd, pw_gecos, pw_dir and pw_shell straight to
add_assoc_string() with no NULL guard, so a NULL string field segfaults the process via
zend_string_init(). glibc's files NSS backend normalizes empty fields to the empty string, but
third-party NSS modules (nss-systemd, nss-ldap, sssd and other directory backends) populate struct
passwd directly and may leave fields NULL. Guard each string field and emit null instead, mirroring
the existing handling already present for the group array in php_posix_group_to_array(). A
deterministic test needs a non-files NSS backend returning NULL, so there is no portable red/green
test; the existing group-path guard is the precedent.