Commit 754ea6e
committed
ext/sockets: memory related issues fix.
- php_if_index_to_addr4()/php_add4_to_if_index() use-after-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_stream() double-close of the stream descriptor on error.
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.
- socket_set_option() data race on the reuseport CBPF filter buffers.
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.
- socket_get_option() leaks uninitialized bytes for sub-int options.
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().
- to_zval_read_iov() missing bail out on oversized iov_len.
The error was recorded but execution fell through to array_init_size() and
the loop with a truncated length. Return right after reporting it.
close GH-227941 parent c1773a1 commit 754ea6e
4 files changed
Lines changed: 12 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1206 | 1206 | | |
1207 | 1207 | | |
1208 | 1208 | | |
| 1209 | + | |
1209 | 1210 | | |
1210 | 1211 | | |
1211 | 1212 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
635 | 635 | | |
636 | 636 | | |
637 | 637 | | |
638 | | - | |
| 638 | + | |
639 | 639 | | |
640 | 640 | | |
641 | 641 | | |
| |||
677 | 677 | | |
678 | 678 | | |
679 | 679 | | |
680 | | - | |
| 680 | + | |
681 | 681 | | |
682 | 682 | | |
683 | 683 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1839 | 1839 | | |
1840 | 1840 | | |
1841 | 1841 | | |
| 1842 | + | |
1842 | 1843 | | |
1843 | 1844 | | |
1844 | 1845 | | |
| |||
1864 | 1865 | | |
1865 | 1866 | | |
1866 | 1867 | | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
1867 | 1872 | | |
1868 | 1873 | | |
1869 | 1874 | | |
| |||
2074 | 2079 | | |
2075 | 2080 | | |
2076 | 2081 | | |
2077 | | - | |
2078 | | - | |
2079 | 2082 | | |
2080 | 2083 | | |
2081 | 2084 | | |
| |||
2357 | 2360 | | |
2358 | 2361 | | |
2359 | 2362 | | |
| 2363 | + | |
2360 | 2364 | | |
2361 | 2365 | | |
2362 | 2366 | | |
| |||
0 commit comments