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

338 Commits

Author SHA1 Message Date
David CARLIER
f830fa9948 Sockets refactoring 2026 (#21365)
ext/sockets: internal refactorings.

- remove redundant memsets and faster socket unix path copy.
- simplify php_open_listen_sock.
- use INADDR_ANY directly instead of resolving via gethostbyname.
- remove redundant memsets in conversions.
2026-03-07 14:09:49 +00:00
Petr Sumbera
ce1cadba29 Fix Solaris tests and add nightly CI job
Closes GH-20709
2026-03-04 10:12:03 +01:00
David Carlier
d01bc9abd1 Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/sockets: socket_sendto() add max addr length control for AF_UNIX.
2026-02-15 21:55:06 +00:00
David Carlier
15163debc5 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/sockets: socket_sendto() add max addr length control for AF_UNIX.
2026-02-15 21:54:54 +00:00
David Carlier
b6495c189a ext/sockets: socket_sendto() add max addr length control for AF_UNIX.
we just mirror what is done for socket_connect()/AF_UNIX type.

close GH-21218
2026-02-15 21:54:19 +00:00
David Carlier
f037d49bb8 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix GH-21161: socket_set_option() crash with array 'addr' entry as null.
2026-02-09 19:27:40 +00:00
David Carlier
1ff5eb448a Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-21161: socket_set_option() crash with array 'addr' entry as null.
2026-02-09 19:27:29 +00:00
David Carlier
19ee3e6697 Fix GH-21161: socket_set_option() crash with array 'addr' entry as null.
in the ipv6 address creation helper we need to use, for the error
message, the converted data rather than assuming the original
is a proper zend_string().

close GH-21166
2026-02-09 19:26:48 +00:00
David Carlier
44d6417bd7 ext/sockets: GH-20532 socket_addrinfo_lookup() sets EAI error code on resolution failures with a new optional argument.
close GH-20534
2026-01-20 20:58:52 +00:00
James Lucas
46e55dd97c ext/sockets: adding Linux's TCP_USER_TIMEOUT constant.
Set TCP_USER_TIMEOUT to cap (ms) how long TCP will wait for ACKs on in-flight data
before aborting the connection; prevents stuck/half-open sessions and
enables faster failover vs default retransmission timeouts.

Co-authored-by: David Carlier <devnexen@gmail.com>

close GH-20708
2025-12-19 07:38:10 +00:00
Jakub Zelenka
2d105afce7 socket: properly expose TCP keepalive constants (#20376)
This fixes missing constants on MacOS where TCP_KEEPALIVE,
TCP_KEEPINTVL and TCP_KEEPCNT are available. Currently only
TCP_KEEPALIVE is defined there.
2025-11-03 19:12:09 +01:00
Gina Peter Banyard
fd1c3660ca ext/sockets: socket_recvfrom() improve error message when port argument is missing 2025-10-13 13:44:19 +01:00
Gina Peter Banyard
4e562f49f3 ext/sockets: socket_recvfrom() add test for missing port argument error message 2025-10-13 13:44:19 +01:00
Gina Peter Banyard
1f131e3ae6 [skip ci] ext/sockets: remove tests that leak memory (#19408)
I don't understand what the purposes of theses tests are.
2025-08-07 21:50:04 +01:00
David Carlier
64852b44b5 ext/sockets: multicast on unsupported socket type error change.
From a mere warning to an exception.

close GH-19114
2025-07-15 13:05:13 +01:00
David CARLIER
46213f879a ext/sockets: socket_addrinfo_lookup narrowing down socket family check to AF_INET/AF_INET6 only. (#19040) 2025-07-12 15:48:25 +01:00
Gina Peter Banyard
40be5fa99f ext/sockets: Remove bool type coercions in tests 2025-06-23 14:56:53 +02:00
David Carlier
5a7920ba60 ext/sockets: socket_shutdown() having proper constants for mode.
close GH-18648
2025-05-26 18:48:21 +01:00
David Carlier
4671f8510c ext/sockets: UDP_SEGMENT support.
UDP segmentation offload is an optimisation attempt by sending multiple
large enough datagrams over UDP which reduces syscalls as by default,
they have to be broke down in small UDP packets, it is better if the
hardware supports it, other handed down to the software implementation.

close GH-18213
2025-05-22 20:32:29 +01:00
Gina Peter Banyard
556e4d9008 streams: Indicate which argument fails the stream ZPP check 2025-03-24 22:54:34 +00:00
David Carlier
d6cd754121 Merge branch 'PHP-8.4' 2025-02-25 21:56:01 +00:00
David Carlier
c8bead8393 Merge branch 'PHP-8.3' into PHP-8.4 2025-02-25 21:55:46 +00:00
David Carlier
8cbc0c57b7 Fix GH-17921 socket_read/socket_recv overflows on buffer size.
update the existing checks to be more straightforward instead of
counting on undefined behavior.

close GH-17923
2025-02-25 21:54:24 +00:00
David CARLIER
cc116067b2 Revert "ext/sockets: follow-up on AF_PACKET support." (#17924)
This reverts commit de018aa2c5.
2025-02-25 07:04:40 +00:00
David Carlier
de018aa2c5 ext/sockets: follow-up on AF_PACKET support.
support from socket_recvfrom and exposing basic PHP userland type.

close GH-17657
2025-02-24 22:09:29 +00:00
Niels Dossche
28751d32c2 Fix nightly failure in socket_afpacket.phpt
Alpine has a slighly differently worded error message, so relax the test:

"unable to retrieve peer name [95]: Not supported"
2025-02-01 12:39:15 +01:00
David Carlier
2ea386a516 ext/sockets: linux AF_PACKET support.
close GH-17440
2025-01-30 12:43:35 +00:00
David Carlier
9f87a19de4 ext/sockets: drop convert_to_array for multicast leave group settings.
close GH-17371
2025-01-06 13:11:07 +00:00
David Carlier
466f3257eb ext/sockets: socket_addrinfo_lookup and other few internal changes
- socket_addrinfo_lookup throws when hints is an indexed array.
- socket_get_option hardcoding size outputs to user when data
  size known.

close GH-17363
2025-01-05 13:32:12 +00:00
David Carlier
c7a322cc4c ext/sockets: follow-up on GH-17300 to check hints value ranges.
close GH-17326
2025-01-04 15:39:53 +00:00
David Carlier
b7c76ded31 ext/socket: socket_addrinfo_lookup check hints array.
close GH-17300
2025-01-02 13:14:10 +00:00
David Carlier
665ebd7f48 ext/sockets: socket_sendto check port range.
close GH-17299
2024-12-29 19:07:19 +00:00
David Carlier
caafa041d9 ext/sockets: socket_bind() check port validity.
range from ephemeral port (0) to max unsigned 16 bits.

close GH-17296
2024-12-29 15:22:05 +00:00
Gina Peter Banyard
9eb228488a ext/sockets: Additional refactorings to socket_set_option() (#17186)
* ext/socket: Reduce scope of variables

* ext/socket: Throw TypeErrors when not passing a string for options requiring one

* ext/sockets: Throw ValueError when string has null bytes for options not passing string length

* ext/sockets: Throw ValueError when string is too long

And replace calls to strlcpy to memcpy
2024-12-29 12:18:15 +00:00
David Carlier
00fe9b205c ext/sockets: socket_create_listen() check port value beforehand.
port is a 16 bit field, limited to the 65535 value then.
Note that 0 is a valid case for ephemeral port.

close GH-17281
2024-12-27 14:29:11 +00:00
David Carlier
4750ce1e6d Merge branch 'PHP-8.4' 2024-12-16 23:00:23 +00:00
David Carlier
eb0e991c5d Merge branch 'PHP-8.3' into PHP-8.4 2024-12-16 22:56:18 +00:00
David Carlier
8a649a8343 ext/sockets: socket_set_option switch from convert_to_long to zval_get_long.
to be explicit when the expected type is not met. Check SO_LINGER values
for possible overflow.

close GH-17135
2024-12-16 22:55:23 +00:00
David Carlier
94d9cc1266 Merge branch 'PHP-8.4' 2024-12-09 13:17:29 +00:00
David Carlier
986dfd4e09 Merge branch 'PHP-8.3' into PHP-8.4 2024-12-09 13:16:50 +00:00
David Carlier
3bea6a2ddb ext/sockets: socket_strerror follow-up on GH-16267 fix.
boundaries should be INT_MIN <= val < INT_MAX in fact.

close GH-16891
2024-12-09 13:16:32 +00:00
David Carlier
ccda20b8d1 ext/sockets: Adding TCP_FUNCTION_BLK socket option for FreeBSD.
Allows to select an alternate TCP stack. For example with RACK,
a fast loss detection relying on timestamp per packet.

While it works system-wide, it can also apply in an individual socket level too.

close GH-16842
2024-11-21 23:00:06 +00:00
David Carlier
33ba1a4ab9 ext/sockets: adding IPPROTO_ICMP* constants for socket creations.
Is to create socket for Internet Control Message Protocol context.
Due to their nature, they are meant to be used via
raw sockets rather than TCP/UDP.

close GH-16737
2024-11-12 18:52:22 +00:00
David Carlier
10dbdc5608 Merge branch 'PHP-8.3' into PHP-8.4 2024-10-12 15:23:48 +01:00
David Carlier
f12e496cba Merge branch 'PHP-8.2' into PHP-8.3 2024-10-12 15:23:35 +01:00
David Carlier
e583890af0 Fix socket_recvfrom overflow on buffer size.
when passing PHP_INT_MAX for the $length param we get this (with ubsan)

`ext/sockets/sockets.c:1409:36: runtime error: signed integer overflow: 9223372036854775807 + 1 cannot be represented in type 'long int'`

close GH-16382
2024-10-12 15:23:03 +01:00
David Carlier
062b3ca2f2 Merge branch 'PHP-8.3' into PHP-8.4 2024-10-06 19:26:10 +01:00
David Carlier
2af32659b3 Merge branch 'PHP-8.2' into PHP-8.3 2024-10-06 19:25:59 +01:00
David Carlier
8537aa687e Fix GH-16267 socket_strerror overflow on argument value.
only socket_strerror provides user-supplied value to sockets_strerror
handler.

close GH-16270
2024-10-06 19:25:38 +01:00
David Carlier
d052d612d9 ext/sockets: adding SOCK_CLOEXEC/SOCK_NONBLOCK options.
targetted for socket_create_pair/socket_create, they re not considered
as socket type but to be ORed with these (to avoid socketpair2/socket2
likely), set O_CLOEXEC/O_NONBLOCK respectively on the file descriptors.

close GH-15322
2024-08-13 08:35:44 +01:00