Bug #79570 [NEW]: ZTS build of PHP 7.3.17 doesn't handle ERANGE for posix_getgrgid and others
| From: | zboszor at pr dot hu | Date: | Wed, 06 May 2020 06:53:48 +0000 |
| Subject: | Bug #79570 [NEW]: ZTS build of PHP 7.3.17 doesn't handle ERANGE for posix_getgrgid and others | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-226934@lists.php.net to get a copy of this message | ||
From: zboszor at pr dot hu
Operating system: Linux
PHP version: 7.3.17
Package: POSIX related
Bug Type: Bug
Bug description:ZTS build of PHP 7.3.17 doesn't handle ERANGE for posix_getgrgid and others
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 bug report at https://bugs.php.net/bug.php?id=79570&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79570&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79570&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79570&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79570&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79570&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79570&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79570&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79570&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79570&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79570&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79570&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79570&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79570&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79570&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79570&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79570&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79570&r=mysqlcfg