diff --git a/NEWS b/NEWS index b52e9b1a136..44da45b565b 100644 --- a/NEWS +++ b/NEWS @@ -38,6 +38,10 @@ PHP NEWS . Fix SplFileInfo::openFile() in write mode. (ndossche) . Fix build on legacy OpenSSL 1.1.0 systems. (Giovanni Giacobbi) +- POSIX: + . Fixed crash on posix groups to php array creation on macos. + (David Carlier) + - SPL: . Fixed bug GH-20678 (resource created by GlobIterator crashes with fclose()). (David Carlier) diff --git a/ext/posix/posix.c b/ext/posix/posix.c index 2c87fbd28d9..85ea03d8cc0 100644 --- a/ext/posix/posix.c +++ b/ext/posix/posix.c @@ -678,7 +678,8 @@ int php_posix_group_to_array(struct group *g, zval *array_group) /* {{{ */ for (count = 0;; count++) { /* gr_mem entries may be misaligned on macos. */ char *gr_mem; - memcpy(&gr_mem, &g->gr_mem[count], sizeof(char *)); + char *entry = (char *)g->gr_mem + (count * sizeof (char *)); + memcpy(&gr_mem, entry, sizeof(char *)); if (!gr_mem) { break; }