mirror of
https://github.com/php/php-src.git
synced 2026-03-28 10:12:18 +01:00
Merge branch 'PHP-8.0'
* PHP-8.0: Support more than NGROUPS_MAX groups on macos
This commit is contained in:
@@ -290,13 +290,21 @@ PHP_FUNCTION(posix_setegid)
|
||||
#ifdef HAVE_GETGROUPS
|
||||
PHP_FUNCTION(posix_getgroups)
|
||||
{
|
||||
gid_t gidlist[NGROUPS_MAX];
|
||||
gid_t *gidlist;
|
||||
int result;
|
||||
int i;
|
||||
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
|
||||
if ((result = getgroups(NGROUPS_MAX, gidlist)) < 0) {
|
||||
/* MacOS may return more than NGROUPS_MAX groups.
|
||||
* Fetch the actual number of groups and create an appropriate allocation. */
|
||||
if ((result = getgroups(0, NULL)) < 0) {
|
||||
POSIX_G(last_error) = errno;
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
gidlist = emalloc(sizeof(gid_t) * result);
|
||||
if ((result = getgroups(result, gidlist)) < 0) {
|
||||
POSIX_G(last_error) = errno;
|
||||
RETURN_FALSE;
|
||||
}
|
||||
@@ -306,6 +314,7 @@ PHP_FUNCTION(posix_getgroups)
|
||||
for (i=0; i<result; i++) {
|
||||
add_next_index_long(return_value, gidlist[i]);
|
||||
}
|
||||
efree(gidlist);
|
||||
}
|
||||
#endif
|
||||
/* }}} */
|
||||
|
||||
Reference in New Issue
Block a user