[php-src] PHP-8.6: Merge branch 'PHP-8.4' into PHP-8.5
| From: | Ilia Alshanetsky | Date: | Tue, 06 Oct 2026 20:40:58 +0000 |
| Subject: | [php-src] PHP-8.6: Merge branch 'PHP-8.4' into PHP-8.5 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-142036@lists.php.net to get a copy of this message | ||
Author: Ilia Alshanetsky (iliaal)
Date: 2026-10-06T16:32:34-04:00
Commit: https://github.com/php/php-src/commit/f3018e97ab347e87028eafe3b16d172d67b0414e
Raw diff: https://github.com/php/php-src/commit/f3018e97ab347e87028eafe3b16d172d67b0414e.diff
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
ext/standard: Retry getpwnam_r() on ERANGE in php_get_uid_by_name()
Changed paths:
A ext/standard/tests/file/chown_user_name.phpt
M NEWS
M ext/standard/filestat.c
Diff:
diff --git a/NEWS b/NEWS
index 64235392b1bd..6d6ed897bd2e 100644
--- a/NEWS
+++ b/NEWS
@@ -235,6 +235,8 @@ PHP NEWS
(Nicolas Grekas)
. Fixed convert.quoted-printable-decode decoding lowercase hex digits to
the wrong byte. (Ilia Alshanetsky)
+ . Fixed chown() and lchown() failing to resolve user names in ZTS builds
+ when getpwnam_r() needs a larger buffer. (Ilia Alshanetsky)
- Tidy:
. Fixed a use-after-free when a tidyNode is used after its document is
diff --git a/ext/standard/filestat.c b/ext/standard/filestat.c
index 85c2517ed91a..ba9950d5de9c 100644
--- a/ext/standard/filestat.c
+++ b/ext/standard/filestat.c
@@ -434,7 +434,7 @@ PHPAPI zend_result php_get_uid_by_name(const char *name, uid_t *uid)
try_again:
err = getpwnam_r(name, &pw, pwbuf, pwbuflen, &retpwptr);
if (err != 0 || retpwptr == NULL) {
- if (err == EAGAIN) {
+ if (err == ERANGE) {
pwbuflen *= 2;
pwbuf = erealloc(pwbuf, pwbuflen);
goto try_again;
diff --git a/ext/standard/tests/file/chown_user_name.phpt
b/ext/standard/tests/file/chown_user_name.phpt
new file mode 100644
index 000000000000..6f8c9b2da1e0
--- /dev/null
+++ b/ext/standard/tests/file/chown_user_name.phpt
@@ -0,0 +1,25 @@
+--TEST--
+chown() and lchown() with a user name
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) == 'WIN') die('skip no windows support');
+if (!function_exists("posix_getpwuid")) die("skip no posix_getpwuid()");
+if (posix_getpwuid(posix_getuid()) === false) die("skip current user has no passwd
entry");
+?>
+--FILE--
+<?php
+$filename = __DIR__ . DIRECTORY_SEPARATOR . 'chown_user_name.txt';
+$name = posix_getpwuid(posix_getuid())['name'];
+
+var_dump(touch($filename));
+var_dump(chown($filename, $name));
+var_dump(lchown($filename, $name));
+?>
+--CLEAN--
+<?php
+@unlink(__DIR__ . DIRECTORY_SEPARATOR . 'chown_user_name.txt');
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(true)