Commit graph

135681 commits

Author SHA1 Message Date
Niels Dossche
ef92e06de1
Fix memory leak on php_odbc_fetch_hash() failure
The array is initialized but not freed.

Closes GH-18787.
2025-06-09 11:24:13 +02:00
Daniil Gentili
9a9d98e02f
Do not delete main chunk in zend_gc
Closes GH-18756.

Co-authored-by: Arnaud Le Blanc <arnaud.lb@gmail.com>
2025-06-09 11:23:29 +02:00
Peter Kokot
ae92b85572
Fix linking ext/curl against OpenSSL (#13262)
This is backport for 8.3 of b222c020bf
that originally targeted only 8.4+. This is however a bug fix.

Following 68f6ab7113, the ext/curl doesn't
need to be linked against OpenSSL anymore, if curl_version_info_data
ssl_version is OpenSSL/1.1 or later.

With OpenSSL 3 and later the check for old SSL crypto locking callbacks
was detected here.

This also uses a common PHP_SETUP_OPENSSL macro for checking OpenSSL and
syncs the minimum OpenSSL version (currently 1.0.2 or later) across the
PHP build system.
2025-06-06 13:51:21 +02:00
Niels Dossche
4162c20787
Fix compile without ZEND_MM_STORAGE 2025-06-05 21:51:30 +02:00
Jakub Zelenka
444cc78a3e
Skip OpenSSL proxy test for bug #74796 on Windows 2025-06-05 16:18:06 +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
David Carlier
e13ba36abb
ext/tidy: anticipate tidyOptIsReadOnly retirement.
using tidyOptGetCategory when possible.

related GH-18751

close GH-18763
2025-06-04 20:32:21 +01:00
Niels Dossche
08a9579883
Fix memory leak of X509_STORE in php_openssl_setup_verify() on failure
Closes GH-18750.
2025-06-03 23:45:51 +02:00
Niels Dossche
9187caeab1
Fix ext/enchant test SKIPIFs
The resource check makes no sense, and the is_array() check doesn't
achieve anything. Drop the former, and replace the latter with a !
check.
Discovered while working on GH-18729.

Closes GH-18731.
2025-06-01 18:21:23 +02:00
Niels Dossche
d8a17ca7c2
Fix test failures in engine_unsafe_empty_string.phpt (#18727)
`/./` matches all characters but newlines, so if `random_bytes`
generates a string with newlines in it, the resulting string is not
empty. Fix this by adding the `s` modifier.
2025-06-01 15:45:36 +02:00
Niels Dossche
d39d261b7e
Fix memory leak in lookup_loc_range()
Closes GH-18723.
2025-06-01 11:38:24 +02:00
Gina Peter Banyard
7f2299c8eb
tests: Fix expectations
Closes GH-18712
2025-05-31 14:45:41 +01:00
Niels Dossche
75cea65c99
Fix reference type confusion and leak in user random engine
Closes GH-18718.

Co-authored-by: Tim Düsterhus <timwolla@googlemail.com>
2025-05-31 15:36:33 +02:00
Niels Dossche
d9d991928f
Fix memory leak when curl_slist_append() fails
If curl_slist_append() returns NULL, then the original pointer is lost
and not freed.

Closes GH-18711.
2025-05-31 11:11:54 +02:00
txuna
48b492269b
Fix GH-18595: fpm_get_status segfault
This fixes null dereference error when calling fpm_get_status() and one
of the children is just being created.

Closes GH-18662

Co-authored-by: Jakub Zelenka <bukka@php.net>
2025-05-30 22:55:53 +02:00
Oleg Efimov
087f38f347
Fix GH-18695: float numbers zero fraction is now preserved in zend_ast_export() (#18699) 2025-05-29 13:46:11 -07:00
Niels Dossche
dd856d5ad9
Fix potential NULL deref
Backported from GH-18697.
2025-05-29 16:57:32 +02:00
Gina Peter Banyard
40422e9c55
ext/pgsql: Fix warning not being emittedd when failure to cancel a query 2025-05-29 15:42:48 +01:00
Niels Dossche
61884c3b52
Fix GH-18642: Signed integer overflow in ext/phar fseek
The overflow checking code already existed, but didn't work because the
math was done on signed numbers instead of unsigned numbers.
In the process I also discovered a pre-existing issue that needs to be
fixed (and seems that other stream wrappers can have this issue too).

Closes GH-18644.
2025-05-28 18:53:55 +02:00
Niels Dossche
fab0a6d75c
Backport fix for GH-17687
Introducing a new attribute macro in lower branches is an ABI break and
not allowed. However, we still need to fix the warnings such that
-Werror builds don't break. So we copy the macro from the master branch
to the C files in the appropriate places.
2025-05-27 20:40:35 +02:00
Niels Dossche
b39e17b06c
Fix memory leak in tidy output handler on error
Closes GH-18649.
2025-05-26 19:41:11 +02:00
Niels Dossche
ff2c7dc0f8
Fix leaks with multiple calls to DatePeriod iterator current()
Destroy the old value first. We can't skip recreating the value because
the object may have been changed in between calls.

Closes GH-18624.
2025-05-26 19:40:41 +02:00
David Carlier
5d4846b241
ext/ldap: simplify ldap_connect() workflow, fix url leak.
delaying the object creation only before ldap initialisation.
fix forgotten url freeing on TLS error code path.

close GH-18645
2025-05-25 12:53:28 +01:00
Máté Kocsis
772479ea2f
Fix build on Apple Clang 17+ (#18629)
Fixing "invalid cpu feature string for builtin" errors that started to appear on Apple Clang 17.0.0
2025-05-24 22:26:06 +02:00
Niels Dossche
a44e3f442f
Fix memory leaks in php_http.c when call_user_function() fails
retval can be refcounted but is not destroyed.

Closes GH-18638.
2025-05-24 21:54:19 +02:00
Niels Dossche
c9781111e1
Fix memory leak when calloc() fails in php_readline_completion_cb()
Closes GH-18637.
2025-05-24 20:39:14 +02:00
Niels Dossche
d6836fb345
Fix memory leak in intl_datetime_decompose()
Closes GH-18635.
2025-05-24 14:55:41 +02:00
David Carlier
c30bddc18f
Fix GH-18617: socket_import_file_descriptor return check.
to_zval_read_fd_array() helper when retrieving the socket protocol did
not check it.

close GH-18617
2025-05-22 20:46:18 +01:00
Niels Dossche
910aeaafc1
Add missing filter cleanups on phar failure
Closes GH-18609.
2025-05-21 19:47:14 +02:00
Jakub Zelenka
8e2c2be7a5
PHP-8.3 is now for PHP 8.3.23-dev 2025-05-21 00:39:56 +02:00
Niels Dossche
1863014fbd
Split off php_set_sock_blocking() and s.is_blocked to a separate function
This makes it harder to forget the check and keeps the variable and
function call consistent.

Closes GH-18604.
2025-05-20 08:08:06 +02:00
Niels Dossche
31ebb42268
Fix missing checks against php_set_blocking() in xp_ssl.c 2025-05-20 08:07:34 +02:00
Niels Dossche
b2d78ae00c
Backport accel_globals->key leak fix (8.3)
Closes GH-18602.
2025-05-19 22:27:54 +02:00
Niels Dossche
41e11a627d
Fix GH-18567: Preloading with internal class alias triggers assertion failure
The assertion is imprecise now, and the code assumed that from the
moment an internal class was encountered that there were only internal
classes remaining. This is wrong now, and we still have to continue if
we encounter an internal class. We can only skip the remaining iterations
if the entry in the hash table is not an alias.

Closes GH-18575.
2025-05-19 19:19:26 +02:00
Niels Dossche
92a0cc7d94
Fix deprecation warning for libxml SAX header (#18594)
This header is deprecated, but fortunately it isn't actually used.
2025-05-19 19:10:27 +02:00
Niels Dossche
98cb17f4fd
Fix OSS-Fuzz #418106144
The VM assumes that an exception must be handled when the AST evaluation
returns FAILURE. However, the comparison functions always return SUCCESS
even if an exception happened. This can be fixed in
zend_ast_evaluate_inner() or we can make is_smaller_function() etc check
for the exception. I chose the former to avoid impact or API breaks.
Perhaps in the future the comparison functions should either return void
or return whether an exception happened, as to be not misleading.

Closes GH-18589.
2025-05-19 19:05:32 +02:00
Niels Dossche
46ac878f6a
Fix OSS-Fuzz #417078295
If the variable_ptr and fetched value are the same or overlap, then we
get a UAF. Prevent this by delaying destruction.

Closes GH-18588.
2025-05-19 19:04:58 +02:00
Levi Morrison
35455b17be
fix: dangling opline in ZEND_INIT_ARRAY (#18578)
This causes problems if an allocation profiler decides to walk the
stack, or if the engine itself OOMs on this opcode, and it tries to
print file and line information.
2025-05-19 09:45:28 -06:00
David Carlier
88d6e7c238
fix regex typo for GH-18577 new test 2025-05-17 12:44:57 +01:00
David Carlier
4dcbd24bad
GH-18572: infinite stack recursion in fallback object comparison.
With nested objects and recursive comparisons, it is for now unavoidable
to have a stack overflow we do some early damage control attempt early
on with zend.max_allowed_stack_size check but ultimately more a band-aid
than a definitive solution.

close GH-18577
2025-05-17 11:20:16 +01:00
George Wang
8e5b3129de Address compiler warnings. 2025-05-15 11:52:49 -04:00
Remi Collet
8da9530652
NEWS 2025-05-15 09:21:58 +02:00
Remi Collet
2760a3ef97
Fix GH-18529: ldap no longer respects TLS_CACERT from ldaprc in ldap_start_tls() Regresion introduced in fix for GH-17776
- ensure TLS string options are properly inherited
  workaround to openldap issue https://bugs.openldap.org/show_bug.cgi?id=10337

- fix ldaps/start_tls tests using LDAPNOINIT in ldaps/tls tests
2025-05-15 09:19:57 +02:00
Tim Düsterhus
8d2682fc50
standard: Take zend.assertions into account for dynamic calls to assert() (#18521)
Fixes php/php-src#18509.
2025-05-12 08:44:46 +02:00
Niels Dossche
e7a44a68e9
Sync EXTENSIONS and extend maintenance time 2025-05-06 22:06:31 +02:00
Ilija Tovilo
69f0882d3b
Fix missing include in win32/globals.c
This previously errored with:

win32\globals.c(66): error C2220: the following warning is treated as an error
win32\globals.c(66): warning C4013: 'php_win32_signal_ctrl_handler_request_shutdown' undefined; assuming extern returning int

This only errors on master because of 2473f57ba (thanks to Niels for
that info!).

Closes GH-18508
2025-05-06 15:51:37 +02:00
Niels Dossche
dcf9d8f812
Fix GH-18494: PDO OCI segfault in statement GC
This is the same issue that was fixed in 2ae897fff7, but now for OCI.

Closes GH-18495.
2025-05-05 19:30:23 +02:00
Niels Dossche
fb3536fd60
Fix leak+crash with sapi_windows_set_ctrl_handler()
The ctrl_handler is never destroyed. We have to destroy it at request
end so we avoid leaking it and also avoid keeping a reference to
previous request memory in a next request. The latter can result in a
crash and can be demonstrated with this script and `--repeat 2`:

```php
class Test {
	public function set() {
		sapi_windows_set_ctrl_handler(self::cb(...));
	}
	public function cb() {
	}
}

$test = new Test;
$test->set();
sleep(3);
```
When you hit CTRL+C in the second request you can crash.

This patch resolves both the leak and crash by destroying the
ctrl_handler after a request.

Closes GH-18231.
2025-05-05 19:13:39 +02:00
David Carlier
8a585856d1
Fix GH-18480: array_splice overflow on array length with offset.
close GH-18483
2025-05-04 14:14:22 +01:00
David Carlier
0227d96f48
Fix GH-18481: date_sunrise check sun rise with offset if is finite/is nan
close GH-18484
2025-05-03 16:56:09 +01:00