go to bug id or search bugs for
I think I've discovered an odd bug. When I use "posix_getgrnam" to print details on a group in /etc/group, I get back nothing. If I erase one entry from the group above it, then it works!
example silly /etc/group file:
Without removing user "kkkk" from "labtest" group, posix_getgrnam can't return the details for group tech!
I expect to see the group details for group "tech".
Add a Patch
Add a Pull Request
The empty result is most likely FALSE; verify this by using
var_dump() instead of print_r().
Also provide the return value of posix_get_last_error(), i.e.
run the following script and post it's output:
You are correct. The output of the script is:
string(29) "Numerical result out of range"
but the group "tech" is a valid system group.
34 is ERANGE. Here it means PHP underestimated the amount of space necessary for a buffer to hold all the information for that group - obviously exhausted by that list of members. It could try again with a larger buffer.
Thanks! Just to confirm - it's therefore a bug in PHP since I can't tell it how much buffer to allocate for the call, right?
The following patch has been added/updated:
Patch Name: try-again
As requinix already said, what apparently happens is that
sysconf(_SC_GETGR_R_SIZE_MAX) returns a size which is insufficient
(which is allowed by the POSIX spec), and so the following
getgrnam_r() fails with ERANGE. posix_getgrnam() could then
try again with an increased (doubled?) buffer size.
Please try the attached patch (try-again).
Automatic comment on behalf of email@example.com
Log: Fix #75696: posix_getgrnam fails to print details of group