1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

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
This commit is contained in:
David Carlier
2025-12-20 22:15:12 +00:00
parent d3ef80649e
commit e63dae2941
2 changed files with 6 additions and 1 deletions

4
NEWS
View File

@@ -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)

View File

@@ -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;
}