1
0
mirror of https://github.com/php/php-src.git synced 2026-04-29 03:03:26 +02:00
Commit Graph

1248 Commits

Author SHA1 Message Date
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
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
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
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
Niels Dossche 7e513a5101 Merge branch 'PHP-8.4'
* PHP-8.4:
  Remove incorrect call to zval_ptr_dtor() in user_wrapper_metadata()
2025-09-04 23:13:50 +02:00
Niels Dossche ad129c6f97 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Remove incorrect call to zval_ptr_dtor() in user_wrapper_metadata()
2025-09-04 23:13:45 +02:00
Niels Dossche d10ff9bbd8 Remove incorrect call to zval_ptr_dtor() in user_wrapper_metadata()
This one is not initialized. This is not hittable from userspace code
because all locations within first-party php-src code have a valid
`option` argument.

Closes GH-19714.
2025-09-04 23:13:20 +02:00
Niels Dossche 4b99519eaa Fix GH-14506: Closing a userspace stream inside a userspace handler causes heap corruption
Use the PHP_STREAM_FLAG_NO_FCLOSE flag to prevent closing a stream while
a handler is running. We already do this in some other places as well.
Only handlers that do something with the stream afterwards need changes.

Closes GH-18797.
2025-09-04 22:05:20 +02:00
Joe Watkins cb9af8d532 Revert "Remove include "sanity check" to get better error (#19650)"
This reverts commit ca4a841921.

We like the error message change, but not the downgrade to notice
at this time in the release cycle.

@bukka will come back around
2025-09-01 14:10:59 +02:00
Nikita Popov ca4a841921 Remove include "sanity check" to get better error (#19650)
* Remove include "sanity check" to get a better error message

Instead of rejecting directories / non-regular files early with
a generic error, we should just accept them and error later when a
read is attempted. This is more general and will generate a better
error message on Linux. On Windows, the error remains the same as
before.

* Update error message to include include_path

fix format for include path

---------

Co-authored-by: Joe Watkins <krakjoe@php.net>
2025-08-31 14:52:53 +02:00
Tim Düsterhus 49faa4df75 uri: Always use const pointers when referring to uri_parser_t (#19623)
The actual parser definitions are all `const` and must never be modified. Make
sure to always use `const` pointers.
2025-08-30 21:04:50 +02:00
Máté Kocsis e9c92a9739 ext/uri: Use the term "URI parser" instead of "URI handler" (#19530) 2025-08-21 07:23:47 +02:00
Máté Kocsis 1cff1815d0 Add internal URI handling API (#19073)
Part of https://github.com/php/php-src/pull/14461. Related to https://wiki.php.net/rfc/url_parsing_api.
2025-08-19 18:35:09 +02:00
Gina Peter Banyard 4d3ccc21d0 main: drop unnecessary zend_{try|catch} in user stream open wrapper
This was initially introduced with https://github.com/php/php-src/commit/9f86cdaf7fc4

However, this should also have been done for the opendir call.
This omission was found via OSS-Fuzz 51047 [1]
and fixed in a more general way in https://github.com/php/php-src/commit/d0b3096ff0f6f6f491833858f126a80f18b81151
by resetting `FG(user_stream_current_filename)` at the end of the request during shutdown.

As such this zend_try/zend_catch block is now unnecessary.

[1]: https://issues.oss-fuzz.com/issues/42515581
2025-08-15 18:41:17 +02:00
Gina Peter Banyard 0992265611 main: refactor userstream method calling
Closes GH-19312
2025-08-15 18:41:17 +02:00
Gina Peter Banyard 4d5bdef21a streams: refactor statbuf_from_array() 2025-08-04 15:30:57 +01:00
Gina Peter Banyard 9e334af6e4 streams: use type php_socket_t instead of type int 2025-08-04 15:30:57 +01:00
Gina Peter Banyard a02b2b8eb6 streams: use %zu printf specifier for size_t
Rather than casting to zend_long
2025-08-04 15:30:57 +01:00
Gina Peter Banyard 051414bec6 streams: use an enum for return type of _php_stream_make_seekable() 2025-08-04 15:30:57 +01:00
Gina Peter Banyard 93ec0ac0f3 streams: drop unused includes 2025-08-04 15:30:57 +01:00
Gina Peter Banyard fa85b38560 streams: voidify php_stream_filter_prepend_ex()
This only ever returned SUCCESS
2025-08-04 15:30:57 +01:00
Gina Peter Banyard fb2585f4e2 streams: use -1 directly instead of FAILURE macro
The result of the functions returning those globals is never checked anyway
2025-08-04 15:30:57 +01:00
Gina Peter Banyard 4b6ebcc6e9 streams: remove confusing step variable 2025-08-04 15:30:57 +01:00
Gina Peter Banyard 02af9acfca streams: use precomputed persistant variable 2025-08-04 15:30:57 +01:00
Gina Peter Banyard 67d6160462 streams: use int type instead of long
The flags variable is passed to the filter virtual function that requires an int
2025-08-04 15:30:57 +01:00
Gina Peter Banyard c9836b03ce streams: use type size_t instead of type unsigned int 2025-08-04 15:30:57 +01:00
Gina Peter Banyard 841afdc486 streams: use type zend_result instead of type int 2025-08-04 15:30:57 +01:00