Skip to content

Commit 0803191

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. close GH-20744
1 parent 22aaa20 commit 0803191

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ PHP NEWS
3333
. Fixed bug GH-20732 (Phar::LoadPhar undefined behavior when reading fails).
3434
(ndossche)
3535

36+
- POSIX:
37+
. Fixed crash on posix groups to php array creation on macos.
38+
(David Carlier)
39+
3640
- SPL:
3741
. Fixed bug GH-20678 (resource created by GlobIterator crashes with fclose()).
3842
(David Carlier)

ext/posix/posix.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,8 @@ int php_posix_group_to_array(struct group *g, zval *array_group) /* {{{ */
678678
for (count = 0;; count++) {
679679
/* gr_mem entries may be misaligned on macos. */
680680
char *gr_mem;
681-
memcpy(&gr_mem, &g->gr_mem[count], sizeof(char *));
681+
char *entry = (char *)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)