Commit graph

941 commits

Author SHA1 Message Date
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
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
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
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
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
b412fd6a77 Merge branch 'PHP-8.2' into PHP-8.3 2024-03-31 17:01:16 +01:00
David Carlier
ba4c82fd80 ext/sockets: socket_create_listen clearing socket data before binding.
Close GH-13855
2024-03-31 17:00:54 +01:00
David Carlier
93d89cb80d Merge branch 'PHP-8.2' into PHP-8.3 2024-03-06 11:39:37 +00:00
David Carlier
e3f0d03452 Fix GH-13603 ext/sockets: properly initialised address info data.
Led to random characters visible on socket id on macOs.

Close GH-13606
2024-03-06 11:37:48 +00:00
twosee
d9b0bdbaa4
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix socket_export_stream() with wrong protocol
2023-09-29 18:58:05 +08:00
twosee
90707f33e1
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix socket_export_stream() with wrong protocol
2023-09-29 18:33:59 +08:00
twosee
b5da98b972
Fix socket_export_stream() with wrong protocol
Closes GH-12310.
2023-09-29 18:33:12 +08:00
Michael Orlitzky
ce8c07e942
ext/sockets/tests/mcast_ipv6_*.phpt: suppress no-ipv6 warning (#11651)
These three tests try to create an ipv6 socket with socket_create() to
determine if they should be skipped. On certain systems lacking ipv6
support, however, the call to socket_create() itself raises a warning:

  BORK Warning: socket_create(): Unable to create socket [97]: Address
  family not supported by protocol in ...

The output is "borked" because the return value (false) is expected
but the text of the warning is not. This commit uses the error control
operator (@) to hide the warning. Afterwards the tests are skipped
normally on such a system.
2023-07-10 16:19:12 +02:00
Ilija Tovilo
45ffa773c8
Merge branch 'PHP-8.2'
* PHP-8.2:
  xfail socket zerocopy test on Cirrus + arm
2023-06-29 08:49:07 +02:00
Ilija Tovilo
838f6bffff
xfail socket zerocopy test on Cirrus + arm
Closes GH-11553
2023-06-29 08:48:48 +02:00
divinity76
4918765d54
SKIP_(SLOW|ONLINE)_TESTS (#11479)
it was missing the SKIP_ONLINE_TESTS check for windows.
2023-06-19 19:44:03 +01:00
Javier Eguiluz
732d92c0e5
[skip ci] Fix various typos and grammar issues (#11143) 2023-04-28 11:05:32 +02:00
David Carlier
7b4b40f06f ext/sockets: addig Linux's IP_BIND_ADDRESS_NO_PORT.
Delay ephemeral port number attribution at connect time rather
than at bind's one.

Close GH-11119.
2023-04-26 19:26:29 +01:00
David CARLIER
6c532df705 ext/sockets adding FreeBSD's SO_REUSEPORT_LB constant.
SO_REUSEPORT_LB is, in fact, closer to the classical Linux's SO_REUSEPORT.

Close GH-11038
2023-04-08 17:35:10 +01:00
Niels Dossche
b606e44abc
Silence compiler warnings in ext/sockets/conversions.c (#10974)
These values will be initialised, but the compiler can't see it.
Write a dummy value to silence this.

Closes GH-10959.
2023-03-29 22:18:29 +02:00
Niels Dossche
efdbb4715e Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix uninitialized variable accesses in sockets/conversions
2023-03-29 19:52:25 +02:00
Niels Dossche
8a1cbdd7df Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix uninitialized variable accesses in sockets/conversions
2023-03-29 19:47:38 +02:00
Niels Dossche
b8755a7559 Fix uninitialized variable accesses in sockets/conversions
This was first pointed out in GH-10959.
The from_zval_... functions don't always write to the pointer, in particular
it is necessary to check for an error before using the value. Otherwise
we can access an uninitialized value and that's UB (and dangerous).

Note: this does *NOT* get rid of the compiler warning. Even though there
is error checking now, the compiler isn't smart enough to figure out
that the values can not be used uninitialized.

Closes GH-10966.
2023-03-29 19:44:30 +02:00
David CARLIER
fbaa2eb059 ext/sockets: add TCP_REPAIR to silently close a connection.
Closes GH-10724.
2023-02-27 22:56:06 +00:00
David Carlier
19a7281efa sockets add SO_RERROR/SO_ZEROIZE/SO_SPLICE net/openbsd's constants.
Closes GH-10563.
2023-02-12 21:55:55 +00:00
George Peter Banyard
735edd1c17 Voidify php_sock_array_from_fd_set() as result is never used 2023-01-30 16:05:30 +00:00
George Peter Banyard
3eb9dd47e0 Use bool and zend_result where it makes sense in sockets extension 2023-01-30 16:05:30 +00:00
David Carlier
908d954de0 sockets updlite protocol support, with checksum coverage settings.
Close GH-10468
2023-01-29 18:19:54 +00:00
Máté Kocsis
7936c8085e
Fix GH-8329 Print true/false instead of bool in error and debug messages (#8385) 2023-01-23 10:52:14 +01:00
David Carlier
f8f7fd2db1 sockets add AF_DIVERT constant.
Allow to bind a socket to a divert port without being concerned
by its address. for ipfw filter purpose (SO_USER_COOKIE constant).
FreeBSD only.

Close GH-10415.
2023-01-22 22:48:45 +00:00
Christoph M. Becker
c8955c078a
Revert GH-10220
Cf. <https://github.com/php/php-src/pull/10220#issuecomment-1383739816>.

This reverts commit ecc880f491.
This reverts commit 588a07f737.
This reverts commit f377e15751.
This reverts commit b4ba16fe18.
This reverts commit 694ec1deea.
This reverts commit 6b34de8eba.
This reverts commit aa1cd02a43.
This reverts commit 308fd311ea.
This reverts commit 16203b53e1.
This reverts commit 738fb5ca54.
This reverts commit 9fdbefacd3.
This reverts commit cd4a7c1d90.
This reverts commit 928685eba2.
This reverts commit 01e5ffc85c.
2023-01-16 12:27:33 +01:00
David Carlier
9198e8894b socket DF flag on UDP socket via IP_MTU_DISCOVER on Linux and IP_DONTFRAGMENT on FreeBSD for path MTU discovery purpose.
idea proposal via ml :
https://marc.info/?l=php-internals&m=167329288509393&w=2

Close GH-10282
2023-01-12 22:22:30 +00:00
Max Kellermann
308fd311ea ext/{standard,json,random,...}: add missing includes 2023-01-10 14:19:03 +00:00
David Carlier
9c2572565a sockets adding TCP_QUICKACK constant.
having tigher control on ACK delays, difference is the setting
is `volatile` as it can be turned off by the kernel if not set
 explicitally set otherwise on the socket.

Closes GH-10145.
2022-12-22 14:50:33 +00:00
David CARLIER
4c4e72f149 socket add socket_atmark support.
checks whether the socket belongs to the out-of-band mark, thus allows to be
 processed accordingly (using the MSG_OOB flag on send/recv).

Closes #9846.
2022-10-31 16:38:18 +00:00
David Carlier
35b5aceff3 SO_ATTACH_REUSEPORT_CBPF filter update. SDK_AD_QUEUE support to attach to a queue.
Closes #9690
2022-10-15 11:22:26 +01:00
Arnaud Le Blanc
5b6f9df51a Merge branch 'PHP-8.2'
* PHP-8.2:
  [ci skip] NEWS
  [ci skip] NEWS
  [ci skip] NEWS
  Return immediately when FD_SETSIZE is exceeded (#9602)
2022-10-01 11:26:17 +02:00
Arnaud Le Blanc
246d13cd99 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  [ci skip] NEWS
  [ci skip] NEWS
  Return immediately when FD_SETSIZE is exceeded (#9602)
2022-10-01 11:24:23 +02:00
Arnaud Le Blanc
d4b99542d5 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  [ci skip] NEWS
  Return immediately when FD_SETSIZE is exceeded (#9602)
2022-10-01 11:23:34 +02:00
Arnaud Le Blanc
80232de0e4
Return immediately when FD_SETSIZE is exceeded (#9602) 2022-10-01 11:20:43 +02:00
Jakub Zelenka
ac7d812fb7
Merge branch 'PHP-8.2' 2022-09-30 17:10:15 +01:00
Jakub Zelenka
d2b7d67dac
Merge branch 'PHP-8.1' into PHP-8.2 2022-09-30 17:08:55 +01:00
Jakub Zelenka
ee8f2c75e0
Merge branch 'PHP-8.0' into PHP-8.1 2022-09-30 17:08:17 +01:00
Andy Postnikov
c58241a003
Make socket path shorter for ext/sockets/tests/socket_cmsg_{rights|credentials}.phpt
When running in CI it fails when path/address is longer 108
2022-09-30 17:07:40 +01:00
David Carlier
615b8006c4 socket module add SO_ATTACH_REUSEPORT_CPBF for Linux.
to be used in conjunction with SO_REUSPORT, giving a greater control
over how we bind a socket instead of the round robin workflow, we do
 instead attach to the processor id as :
- we assign the processor_id to A in the BPF filter.
- then returns A.

in other words, a more modern version of SO_INCOMING_CPU (ie can have a per
 worker notion we do not use here).
Closes #8062
2022-09-29 23:32:39 +01:00
Christoph M. Becker
5fdf95b217
Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-9574: SOCKET_EPROTO constant missing since PHP 8.2 dev
2022-09-19 14:42:03 +02:00
Christoph M. Becker
4767b0999d
Fix GH-9574: SOCKET_EPROTO constant missing since PHP 8.2 dev
Closes GH-9575.
2022-09-19 14:41:30 +02:00
Ilija Tovilo
743d3780c6
Add clang ASAN/UBSAN push job
Closes GH-9507
2022-09-14 23:55:46 +02:00