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

6151 Commits

Author SHA1 Message Date
Jakub Zelenka
404b4c816a PHP-8.3 is now for PHP-8.3.31 2025-12-30 13:14:00 +01:00
Niels Dossche
ee0143887d Fix GH-20352: UAF in php_output_handler_free via re-entrant ob_start() during error deactivation
The problem is that the code is doing `php_output_handler_free` in a loop on the output stack,
but prior to freeing the pointer on the stack in `php_output_handler_free` it calls
`php_output_handler_dtor` which can run user code that reallocates the stack,
resulting in a dangling pointer freed by php_output_handler_free.
Furthermore, OG(active) is set when creating a new output handler, but
the loop is supposed to clean up all handlers, so OG(active) must be
reset as well.

Closes GH-20356.
2025-12-19 19:36:26 +01:00
Eric Mann
e10f6d702f PHP-8.3 is now for PHP 8.3.30-dev 2025-12-02 09:05:38 -08:00
David Carlier
4312a446d0 Fix GH-20601: ftp_connect() timeout argument overflow.
close GH-20603
2025-11-29 23:05:14 +00: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
17f253a1f2 PHP-8.3 is now for PHP 8.3.29-dev 2025-11-04 15:13:43 +01: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
Eric Mann
91eb2a558d PHP-8.3 is now for PHP 8.3.28-dev 2025-10-07 06:58:36 -07: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
288d698ce4 Prevent use after stack scope in stream strerr code (#20040) 2025-10-02 19:22:28 +02:00
Jakub Zelenka
a3c14d6ab4 Do not use errno_t as it is not defined on musl (#20037) 2025-10-02 13:42:11 +02: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
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
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
93bac8cb1a Fix GH-19922: gzopen() double free
close GH-19924
2025-09-29 22:47:29 +01:00
Niels Dossche
7a1bb71127 Fix GH-19480: error_log php.ini cannot be unset when open_basedir is configured
Since the ini message handlers already check for basedir, we need to
drop the basedir check from ini_set. Then we also fix the exceptional
case for the empty string: it should bypass the basedir check.
Furthermore, there was a regression introduced with the error_log
"syslog" check in ddfe269a (inverted check), so we fix that as well.

Closes GH-19487
2025-09-19 14:14:53 +02:00
Jakub Zelenka
c9cc68b9ed PHP-8.3 is now for PHP-8.3.27-dev 2025-09-09 23:02:24 +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
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
Eric Mann
a0bd2c9fcf PHP-8.3 is now for PHP 8.3.26-dev 2025-08-12 08:15:40 -07:00
dixyes
5dd965117a Free opened_path when opened_path_len >= MAXPATHLEN
Closes GH-19240.
2025-07-27 10:54:21 +02:00
Jakub Zelenka
faf833bffc PHP 8.3 is now for PHP-8.3.25-dev 2025-07-16 14:09:24 +02:00
Jakub Zelenka
cf0c39723e Fix GHSA-3cr5-j632-f35r: Null byte in hostnames
This fixes stream_socket_client() and fsockopen().

Specifically it adds a check to parse_ip_address_ex and it also makes
sure that the \0 is not ignored in fsockopen() hostname formatting.
2025-07-01 09:34:23 -07:00
Jakub Zelenka
a36b8fdc94 Fix GH-13264: fgets() and stream_get_line() do not return false on filter fatal error
This happens because there are no checks in php_stream_fill_read_buffer
calls. This should not fail always but only on fatal error so special
flag is needed for that.

Closes GH-18778
2025-06-21 20:13:09 +02:00
Eric Mann
50606f8569 PHP 8.3 is now for PHP 8.3.24-dev 2025-06-17 08:06:35 -07:00
Niels Dossche
fe3bea090e Fix technically incorrect sizeof
This doesn't actually matter because both `*sal` and `**sal` are pointer
sized, but this makes analysers happy.
Fixes bug #68866.

Closes GH-18816.
2025-06-09 22:05:09 +02:00
Jakub Zelenka
42f6c15186 Fix bug #74796: Requests through http proxy set peer name
This issue happens because http wrapper sets peer_name but then does not
remove so it stays in the context. The fix removes the peer name from
the context after enabling crypto.

In addition to bug #74796, this also fixes bug #76196.

In addition it should be a final fix for those SOAP bugs:

bug #69783
bug #52913
bug #61463
2025-06-05 14:08:28 +02:00
Jakub Zelenka
8e2c2be7a5 PHP-8.3 is now for PHP 8.3.23-dev 2025-05-21 00:39:56 +02:00
Eric Mann
2852177f4d PHP-8.3 is now for PHP 8.3.22-dev 2025-04-22 06:09:24 -07:00
Niels Dossche
81d9a27c47 Fix some leaks in php_scandir
Closes GH-18371.
2025-04-21 13:20:45 +02:00
David Carlier
2e47442a6b Fix GH-18212: fseek with SEEK_CUR and negative offset crash on debug
Triggers the assertion as with SEEK_CUR the stream position is set to a
negative value so we force the failure without affecting its position
instead.

close GH-18224
2025-04-02 12:34:50 +01:00
Jakub Zelenka
b57f425cfe PHP 8.3 is now for PHP 8.3.21-dev 2025-03-25 22:09:16 +01:00
Eric Mann
517d7d909d PHP-8.3 is now for PHP-8.3.20-dev 2025-03-12 06:34:55 -07:00
Eric Mann
00a772bf94 PHP-8.3 is now for PHP 8.3.19-dev 2025-02-25 09:20:39 -08:00
Jakub Zelenka
930624899b Fix bug #72666: stat cache not cleared for plain paths
This adds more aggressive clearing of stat cache. It is added to the
filestat as well as plain wrapper operations which covers stream file
accessing as well as exec functions (using pipes). It should hopefully
fix the most visible issues with the stat cache.

Closes GH-17681
2025-02-24 23:21:45 +01:00
David Carlier
0f63bee3e9 Fix GH-17797: zend_test_compile_string crash on invalid script path.
When looking for the last slash of the script path, it leads to
underflow being promoted to SIZE_MAX being way beyond MAXPATHLEN.

close GH-17801
2025-02-15 10:11:27 +00:00
Niels Dossche
678ecff980 Fix memory leak on overflow in _php_stream_scandir()
On overflow, only the array is freed, but not the strings.

Closes GH-17789.
2025-02-14 23:08:43 +01:00
Jakub Zelenka
c4b678fa70 PHP-8.3 is now for PHP 8.3.18-dev 2025-01-28 19:45:52 +01:00
Eric Mann
717b75cb43 PHP-8.3 is now for PHP-8.3.17-dev 2024-12-31 08:46:21 -08:00
Christoph M. Becker
53b69ba8cf Fix GH-17067: glob:// wrapper doesn't cater to CWD for ZTS builds
`glob(3)` doesn't know the virtual CWD of PHP, so we need to pass an
absolute path for ZTS builds.  In lack of a reusable routine, we copy
the code from `glob()` and adapt as needed.

Closes GH-17074.
2024-12-18 13:02:48 +01:00
Jakub Zelenka
b1e3dcf88a PHP-8.3 is now for PHP 8.3.16-dev 2024-12-03 18:45:43 +01:00
Niels Dossche
4eaa6f9d4e Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16998: UBSAN warning in rfc1867
2024-12-01 10:59:59 +01:00
Niels Dossche
aab784263d Fix GH-16998: UBSAN warning in rfc1867
The "else branch" of `next_line` can reset the `buf_begin` field to
NULL, causing the next invocation to pass NULL to `memchr` with a 0
length. When UBSAN is enabled this causes an UBSAN abort. Real world
impact is likely none because of the 0 length.

To fix this, don't set the pointer to NULL, which means that the
`memchr` will return NULL and since
`self->bytes_in_buffer < self->bufsize` we return NULL and request more
data through `fill_buffer`. That function will reset `buf_begin` and
`bytes_in_buffer` so that the next invocation works fine.

I chose this solution so we have an invariant that `buf_begin` is never
NULL, which makes reasoning easier. An alternative solution is keeping
the NULLing of `buf_begin` and add an extra check at the top of
`next_line`, but I didn't like special casing this.

Closes GH-17000.
2024-12-01 10:59:30 +01:00
Jakub Zelenka
6f05d96a2b Merge branch 'PHP-8.2' into PHP-8.3 2024-11-29 07:56:28 +01:00
Jakub Zelenka
69765d9220 Fix network connect poll interuption handling
When connecting to socket, it is possible to get EINTR. In such case,
there should be an another attempt to connect if we are not over the
timeout. The timeout should be adjusted accordingly in that case.

This fixes https://github.com/phpredis/phpredis/issues/1881

Closes GH-16606
2024-11-29 07:54:06 +01:00
Christoph M. Becker
929d42de50 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16849: Error dialog causes process to hang
2024-11-25 23:08:11 +01:00
Christoph M. Becker
e75061b512 Fix GH-16849: Error dialog causes process to hang
If `_DEBUG` is set, assertion failures and errors are directed to a
debug message window by default[1].  That causes a process to hang,
since these dialogs are modal.  While we already cater to assertion
failures, errors have apparently been overlooked.

We choose a minimal fix for BC reasons; although passing `0` as
`reportMode` is undocumented, it obviously works fine for a long time.
We may consider to improve on this for the `master` branch.

[1] <https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/crtsetreportmode>

Closes GH-16850.
2024-11-25 23:04:51 +01:00
Pierrick Charron
f5895792e7 PHP-8.2 is now for PHP 8.2.27-dev 2024-11-05 12:47:25 -05:00
Eric Mann
9c79ca74ef PHP-8.3 is now for PHP-8.3.15-dev 2024-11-05 07:00:09 -08:00
Jakub Zelenka
6f868bd6db PHP-8.3 is now for PHP-8.3.14-dev 2024-10-08 19:21:43 +01:00