Bug #79570 [Ver->Csd]: ZTS build of PHP 7.3.17 doesn't handle ERANGE for posix_getgrgid and others
| From: | nikic@php.net | Date: | Fri, 19 Jun 2020 15:33:02 +0000 |
| Subject: | Bug #79570 [Ver->Csd]: ZTS build of PHP 7.3.17 doesn't handle ERANGE for posix_getgrgid and others | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-227558@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79570&edit=1
ID: 79570
Updated by: nikic@php.net
Reported by: zboszor at pr dot hu
Summary: ZTS build of PHP 7.3.17 doesn't handle ERANGE for
posix_getgrgid and others
-Status: Verified
+Status: Closed
Type: Bug
Package: POSIX related
Operating System: Linux
PHP Version: 7.3.17
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of zboszor@pr.hu
Revision: http://git.php.net/?p=php-src.git;a=commit;h=6aff9a50cae40582d2571e7aa6f336d5c6a99547
Log: Fixed bug #79570
Previous Comments:
------------------------------------------------------------------------
[2020-06-17 17:59:16] alexdowad@php.net
Can you submit the attached patch as a pull request to php-src in GitHub? Perhaps it may get more
attention there. If you do not want to do this, I could also submit it on your behalf and credit you
in the commit message.
------------------------------------------------------------------------
[2020-05-06 07:10:30] cmb@php.net
Thanks for reporting! This has been missed when fixing bug
#75696.
------------------------------------------------------------------------
[2020-05-06 06:53:48] zboszor at pr dot hu
Description:
------------
ZTS build of PHP uses getgrnam_r, getgrgid_r, getpwnam_r and getpwuid_r
behind their respective posix_* functions. These functions may return ERANGE
if the buffer supplied by the caller is too small.
sysconf() returns 1024 for _SC_GETGR_R_SIZE_MAX and _SC_GETPW_R_SIZE_MAX.
Only posix_getgrnam calling getgrnam_r handles ERANGE properly by
retrying with a larger buffer.
This was noticed on a system with a group containing many users, so
the respective line in /etc/group exceeded 2KB.
Test script:
---------------
<?php
$i = 200; /* a GID that has a very long line in /etc/group */
$data = posix_getgrgid($i);
$error_num = posix_get_last_error();
if ($error_num > 0) {
echo "\nERROR NUM = $error_num\n";
echo "ERROR MES = " . posix_strerror($error_num) . "\n\n";
} else {
printf("%s\n", $data["name"]);
}
?>
Expected result:
----------------
The group name should be printed.
Actual result:
--------------
Error number 34 (ERANGE) is printed.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79570&edit=1