Skip to content

ext/sockets: various memory related fixes#22794

Open
devnexen wants to merge 5 commits into
php:PHP-8.4from
devnexen:socket_mem_fixes
Open

ext/sockets: various memory related fixes#22794
devnexen wants to merge 5 commits into
php:PHP-8.4from
devnexen:socket_mem_fixes

Conversation

@devnexen

Copy link
Copy Markdown
Member

No description provided.

devnexen added 5 commits July 17, 2026 20:06
…-free on the Windows address table.

GetIpAddrTable() was retried against addr_table after an erealloc() whose
return value was discarded, so on ERROR_INSUFFICIENT_BUFFER it wrote into
the freed block. Assign the reallocated pointer back before retrying.
socket_import_file_descriptor() sets bsd_socket before zstream is copied,
so a failing import freed the object with zstream still UNDEF and closed
the fd still owned by the stream. Invalidate bsd_socket on the error path.
The cbpf/bpfprog buffers were function-local statics shared across threads,
so concurrent SO_ATTACH_REUSEPORT_CBPF calls could install a torn filter.
Move them to function scope so they outlive the block up to setsockopt()
without being shared.
The generic path only corrected 1-byte options; an option returning 0/2/3
bytes left the high bytes of other_val uninitialized before RETURN_LONG.
Zero-initialize it before getsockopt().
The error was recorded but execution fell through to array_init_size() and
the loop with a truncated length. Return right after reporting it.
@devnexen devnexen changed the title Socket mem fixes ext/sockets: various memory related fixes Jul 17, 2026
@devnexen
devnexen marked this pull request as ready for review July 17, 2026 19:31
@devnexen
devnexen requested a review from Girgias July 17, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant