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

1271 Commits

Author SHA1 Message Date
Ilija Tovilo
0039af028c Propagate bind error for stream_socket_server()
When stream_socket_server() fails during bind(), we're currently only showing
"Unknown error" in the error message. Properly propagate this error for better
diagnostics.

Closes GH-21328
2026-03-16 08:53:38 +01:00
Ilija Tovilo
92ba1e4ea0 Prevent closing of innerstream of php://temp stream
Fixes GH-21221
Closes GH-21222
2026-03-13 20:34:04 +01:00
ndossche
bfd66bbdf0 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix compile warnings under GCC 15.2.1 (#21320)
  Updated to version 2026.1 (2026a)
2026-03-02 23:13:40 +01:00
ndossche
210704258a Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix compile warnings under GCC 15.2.1 (#21320)
2026-03-02 23:12:48 +01:00
Nora Dossche
583be5a8ca Fix compile warnings under GCC 15.2.1 (#21320)
The compiler now infers constness through string functions.
Adhere to that.
It also now warns about using multiplications in conditions.
2026-03-02 23:12:06 +01:00
Peter Kokot
8032d6fa16 Autotools: Check struct stat.st_blocks with AC_CHECK_MEMBERS (#13562)
The AC_STRUCT_ST_BLOCKS expects fileblocks object to be compiled with
AC_LIBOBJ if stat.st_blocks is missing on the system. This can be
simplified with the usual AC_CHECK_MEMBERS since PHP is using the
stat.st_blocks (and stat.st_blksize) conditionally.

These members are mostly present on all POSIX-based systems except on
Windows these days.

This also removes the obsolete HAVE_ST_BLOCKS symbol:
https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/types.m4?h=v2.72#n1055

Additionally, the st_blksize and st_blocks members are checked
conditionally with HAVE_ preprocessor macros. Instead of filtering
Windows specifically here, the preprocessor macros
HAVE_STRUCT_STAT_ST_BLKSIZE and HAVE_STRUCT_STAT_ST_BLOCKS can be used.
2026-02-10 19:59:10 +01:00
Arnaud Le Blanc
65b4073922 Include the actual stub name in generated arginfo headers (#20993) 2026-01-21 20:57:00 +01:00
Niels Dossche
4c9bbaa79d Merge branch 'PHP-8.5'
* PHP-8.5:
  streams/memory: Ensure internal string is NUL terminated (#20812)
2026-01-02 18:03:41 +01:00
Niels Dossche
de1465e5ae Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  streams/memory: Ensure internal string is NUL terminated (#20812)
2026-01-02 18:03:36 +01:00
Niels Dossche
5484ebcc49 streams/memory: Ensure internal string is NUL terminated (#20812)
zend_string_truncate() doesn't put a NUL byte.
2026-01-02 18:03:17 +01:00
Jakub Zelenka
e49be5f8e2 Allow filtered streams to be casted as fd for select
This removes the artificial limitation that is not necessary. The fact
that some streams can have some data buffered is not a problem because
the similar situation is already present for OpenSSL streams where
OpenSSL can internally buffer data for the unprocessed part of the
record.

Closes GH-20540
2026-01-01 20:51:23 +01:00
Jakub Zelenka
ab5c2a826a Use long conversion for stream context keepalive int values (#20805)
This is consistent with http and ssl wrappers where int values
are converted in this way.
2025-12-30 22:08:35 +01:00
Jakub Zelenka
0fd8aae6e8 Fix TCP_KEEPALIVE no inheriting for accepted sockets on MacOS 2025-12-30 16:53:22 +01:00
Jakub Zelenka
9582d8e6d7 Add stream socket keepalive context options
This adds so_keepalive, tcp_keepidle, tcp_keepintvl and tcp_keepcnt
stream socket context options that are used to set their upper case
C macro variants by setsockopt function.

The test requires sockets extension and just tests that the values are
being set. This is because a real test would be slow and difficult to
show that those options really work due to how they work internally.

Closes GH-20381
2025-12-30 16:52:22 +01:00
Niels Dossche
eb733a3127 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-20286: use-after-destroy during userland stream_close()
2025-11-23 17:51:35 +01:00
Niels Dossche
27f17c3322 Fix GH-20286: use-after-destroy during userland stream_close()
Closes GH-20493.

Co-authored-by: David Carlier <devnexen@gmail.com>
2025-11-23 17:46:28 +01:00
Jakub Zelenka
aead67d0bb Add so_reuseaddr stream socket context option
This is to allow disabling of SO_REUSEADDR that is enabled by default.

To achieve better compatibility on Windows SO_EXCLUSIVEADDRUSE is set
if so_reuseaddr is false.

Closes GH-19967
2025-11-03 11:44:09 +01:00
Niels Dossche
5d0499af7e Don't duplicate protoname for stream wrappers (#20292)
This is never used.
2025-10-26 08:39:33 +01:00
Jakub Zelenka
b3d846521b Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix GH-19798: XP_SOCKET XP_SSL: Incorrect condition for Win
2025-10-23 15:28:55 +02:00
Jakub Zelenka
45451740e3 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-19798: XP_SOCKET XP_SSL: Incorrect condition for Win
2025-10-23 15:26:05 +02:00
Jakub Zelenka
2a0931d347 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-19798: XP_SOCKET XP_SSL: Incorrect condition for Win
2025-10-23 15:22:21 +02:00
Jakub Zelenka
eef11e048d Fix GH-19798: XP_SOCKET XP_SSL: Incorrect condition for Win
This fixes incorrect type conversion and subsequent check for Windows
where returned socket is not an int.

It should be noted that this is not really an issue as previous int
would get negative so the check should still work. The issue actually
happens only in master (PHP 8.5) where refactoring has been done and the
type changed.

Closes GH-19881
2025-10-23 15:11:14 +02:00
Tim Düsterhus
985d681501 tree-wide: Replace zval_is_true() by zend_is_true() (#20065)
* tree-wide: Replace `zval_is_true()` by `zend_is_true()`

The former is a direct alias of the latter which is much more often used.

* zend_operators: Remove `zval_is_true()`
2025-10-07 20:44:32 +02:00
Niels Dossche
a9c581b1cc Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix GH-19570: unable to fseek in /dev/zero and /dev/null
2025-10-06 18:16:56 +02:00
Niels Dossche
ff7e1e7105 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-19570: unable to fseek in /dev/zero and /dev/null
2025-10-06 18:16:48 +02:00
Niels Dossche
2edb369181 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-19570: unable to fseek in /dev/zero and /dev/null
2025-10-06 18:16:37 +02:00
Niels Dossche
b7aeb0a69f Fix GH-19570: unable to fseek in /dev/zero and /dev/null
On Linux, these two character devices are exceptions in that they can be
seeked. Check their major/minor device number.

Co-authored-by: divinity76 <hans@loltek.net>
2025-10-06 18:16:16 +02:00
Niels Dossche
3c2a570a22 Remove useless zval_ptr_dtor() in php_userstreamop_write()
At this point, retval is either false or converted to a long.
2025-10-04 09:53:28 +02:00
Jakub Zelenka
010e178a40 Merge branch 'PHP-8.4' into PHP-8.5 2025-10-02 19:23:26 +02:00
Jakub Zelenka
57e1438ca5 Merge branch 'PHP-8.3' into PHP-8.4 2025-10-02 19:22:59 +02:00
Jakub Zelenka
288d698ce4 Prevent use after stack scope in stream strerr code (#20040) 2025-10-02 19:22:28 +02:00
Jakub Zelenka
e68396cb39 Prevent use after stack scope in stream strerr code (#20040) 2025-10-02 19:20:49 +02:00
David Carlier
7760e43ad1 Merge branch 'PHP-8.4' into PHP-8.5 2025-10-02 12:31:59 +01:00
David Carlier
3193fe0728 Merge branch 'PHP-8.3' into PHP-8.4 2025-10-02 12:30:41 +01:00
David Carlier
175afc4085 Fix GH-19705: do not flush/write buffer on non writeable stream.
Co-authored-by: Jakub Zelenka <bukka@php.net>

close GH-19708
2025-10-02 12:28:36 +01:00
Niels Dossche
31fefe0e09 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-17345: Bug #35916 was not completely fixed
2025-10-01 11:50:12 +02:00
Niels Dossche
7dd7ad843d Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17345: Bug #35916 was not completely fixed
2025-10-01 11:50:05 +02:00
Niels Dossche
0ffa337a54 Fix GH-17345: Bug #35916 was not completely fixed
Change the reproducer code in `bug35916.phpt` from `stream_bucket_append` to
`stream_bucket_prepend` and you have the same bug.
Furthermore, even in the append case the check is incorrect because the bucket
can already be in the brigade at a position other than the tail.
To solve this properly, unlink the brigade first and also use that as a
condition to manage the refcount.

Closes GH-18973.
2025-10-01 11:49:28 +02:00
Jakub Zelenka
879d5e9b88 Merge branch 'PHP-8.4' into PHP-8.5 2025-10-01 11:14:27 +02:00
Jakub Zelenka
152dfa8835 Merge branch 'PHP-8.3' into PHP-8.4 2025-10-01 11:12:42 +02:00
Jakub Zelenka
b7fdfb7147 Fix GH-19248: Use strerror_r instead of strerror in main
Or on Windows it is going to use either FormatMessageW or strerror_s
for compatibility with previous error messages.

It also needs to accomodate for GNU and BSD versions of strerror_r
returning different type.

Closes GH-19251
2025-10-01 11:12:08 +02:00
David Carlier
ed9c1b87ee Merge branch 'PHP-8.4' into PHP-8.5 2025-09-29 22:48:55 +01:00
David Carlier
03de7b0b28 Merge branch 'PHP-8.3' into PHP-8.4 2025-09-29 22:48:38 +01:00
David Carlier
93bac8cb1a Fix GH-19922: gzopen() double free
close GH-19924
2025-09-29 22:47:29 +01:00
Tim Düsterhus
26eac7de17 uri: Clean up naming of public symbols (#19794)
* uri: Rename `uri_recomposition_mode_t` to `php_uri_recomposition_mode`

* uri: Align the names of the `php_uri_recomposition_mode` values

* uri: Rename `uri_component_read_mode_t` to `php_uri_component_read_mode`

* uri: Align the names of the `php_uri_component_read_mode` values

* uri: Rename `uri_property_name_t` to `php_uri_property_name`

* uri: Align the names of the `php_uri_property_name` values

* uri: Rename `uri_property_handler_t` to `php_uri_property_handler`

* uri: Rename `uri_(read|write)_t` to `php_uri_property_handler_(read|write)`

* uri: Rename `php_uri_property_handler`’s `(read|write)_func` to `read|write`

The `_func` is implied by the data type and the name of the struct.

* uri: Rename `uri_parser_t` to `php_uri_parser`

* uri: Shorten the names of `php_uri_parser` fields

The `_uri` suffix is implied, because this is an URI parser.
2025-09-11 12:10:41 +02:00
Niels Dossche
1869eff6ee Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix OSS-Fuzz #385993744
2025-09-08 19:10:46 +02:00
Niels Dossche
89f2805905 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix OSS-Fuzz #385993744
2025-09-08 19:10:41 +02:00
Niels Dossche
ff84cb08ef Fix OSS-Fuzz #385993744
PSFS_FEED_ME is supposed to be returned when the filter did not receive
enough data and did not generate buckets for the output brigade.
The test generates buckets anyway on the output brigade, and the stream
layer did not handle that case causing a memory leak.
To solve this, discard any such buckets as it would conflict with the
status code returned by the filter. This keeps BC and solves the leak.

Closes GH-18972.
2025-09-08 19:10:22 +02:00
Niels Dossche
b5817cc4c3 Remove pointless zval_ptr_dtor() calls in userspace stream handling (#19712)
These act on LONGs, so dtor'ing them is pointless.
2025-09-07 13:26:20 +02:00
Niels Dossche
d0630e850b Avoid double conversion to string in php_userstreamop_readdir()
The string is converted twice for some reason.
This is pointless, and furthermore, this is observable in userspace code
when dealing with Stringable objects.

Closes GH-19713.
2025-09-04 23:14:22 +02:00