Skip to content

Commit 0f25a05

Browse files
committed
ext/posix: (Further) fix groups array creation on macos.
With macos Tahoe and clang "17.0.0" (Xcode) the ext/posix/tests/posix_getgrgid_macosx.phpt test crashes as follow: ext/posix/posix.c:681:19: runtime error: load of misaligned address 0x60800000e972 for type 'char **', which requires 8 byte alignment 0x60800000e972: note: pointer points here 70 00 2a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 seems memcpy had been translated to a load instruction ? anyhow, we force to copy a "proper" char * source.
1 parent 22aaa20 commit 0f25a05

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ext/posix/posix.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,9 +676,10 @@ int php_posix_group_to_array(struct group *g, zval *array_group) /* {{{ */
676676
add_assoc_null(array_group, "passwd");
677677
}
678678
for (count = 0;; count++) {
679+
char *entry = (char *)g->gr_mem + (count * sizeof (char *));
679680
/* gr_mem entries may be misaligned on macos. */
680681
char *gr_mem;
681-
memcpy(&gr_mem, &g->gr_mem[count], sizeof(char *));
682+
memcpy(&gr_mem, entry, sizeof(char *));
682683
if (!gr_mem) {
683684
break;
684685
}

0 commit comments

Comments
 (0)