summaryrefslogtreecommitdiff
path: root/ext/posix
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-06-20 16:06:54 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-06-20 17:24:06 +0200
commitd80f0ff6c0a557d8c993a9d2bd006fb488f6d564 (patch)
tree2b50eccd81bb69d69eb05085367255dca0a05a83 /ext/posix
parenta768271d9160be5181533db14a21a68869931885 (diff)
downloadphp-git-d80f0ff6c0a557d8c993a9d2bd006fb488f6d564.tar.gz
Handle gr_mem misalignment on macos
Diffstat (limited to 'ext/posix')
-rw-r--r--ext/posix/posix.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/ext/posix/posix.c b/ext/posix/posix.c
index e95064d0fa..98dae1ca3c 100644
--- a/ext/posix/posix.c
+++ b/ext/posix/posix.c
@@ -998,8 +998,15 @@ int php_posix_group_to_array(struct group *g, zval *array_group) /* {{{ */
} else {
add_assoc_null(array_group, "passwd");
}
- for (count = 0; g->gr_mem[count] != NULL; count++) {
- add_next_index_string(&array_members, g->gr_mem[count]);
+ for (count = 0;; count++) {
+ /* gr_mem entries may be misaligned on macos. */
+ char *gr_mem;
+ memcpy(&gr_mem, &g->gr_mem[count], sizeof(char *));
+ if (!gr_mem) {
+ break;
+ }
+
+ add_next_index_string(&array_members, gr_mem);
}
zend_hash_str_update(Z_ARRVAL_P(array_group), "members", sizeof("members")-1, &array_members);
add_assoc_long(array_group, "gid", g->gr_gid);