Commit graph

135692 commits

Author SHA1 Message Date
Jakub Zelenka
5e5b164bb4
Update NEWS with entries for security fixes 2025-06-26 11:29:28 +02:00
Ahmed Lekssays
026ab919d0
Fix GHSA-453j-q27h-5p8x
Libxml versions prior to 2.13 cannot correctly handle a call to
xmlNodeSetName() with a name longer than 2G. It will leave the node
object in an invalid state with a NULL name. This later causes a NULL
pointer dereference when using the name during message serialization.

To solve this, implement a workaround that resets the name to the
sentinel name if this situation arises.

Versions of libxml of 2.13 and higher are not affected.

This can be exploited if a SoapVar is created with a fully qualified
name that is longer than 2G. This would be possible if some application
code uses a namespace prefix from an untrusted source like from a remote
SOAP service.

Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2025-06-24 23:34:55 +02:00
Jakub Zelenka
65eade719f
Fix GHSA-hrwm-9436-5mv3: pgsql escaping no error checks
This adds error checks for escape function is pgsql and pdo_pgsql
extensions. It prevents possibility of storing not properly escaped
data which could potentially lead to some security issues.
2025-06-23 23:32:30 +02:00
Jakub Zelenka
c074645ac3
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-06-23 23:06:22 +02:00
Niels Dossche
afb1c57470
Fix GH-14551: PGO build fails with xxhash
Turns out that the instrumentation added for gcov can change inlining
decisions of the compiler, which results in a mismatch between the
profile data CFG and the actual generated CFG between compiles.

There are two functions that suffer from this issue:
1. _PHP_XXH3_Init: Removing the inline hint fixes this one. In fact,
   always inlining this makes no sense as there's no real opportunity
   for specialising. It just bloats the binary and increases I$ pressure.
   So besides fixing this issue it's beneficial on its own to drop the
   attribute.
2. PHP_XXH3_128_Final: Sometimes XXH128_canonicalFromHash gets inlined
   and sometimes not. Make sure it gets always inlined.

Closes GH-18814.
2025-06-12 19:26:28 +02:00
Niels Dossche
0cd3ebfc40
Fix 'phpdbg --help' segfault on shutdown with USE_ZEND_ALLOC=0
This hack not only breaks the handling of custom allocators, but also
breaks if zend_alloc is compiled with USE_CUSTOM_MM.
This hack is just no good, if you want leak information then use ASAN.

Closes GH-18813.
2025-06-10 19:22:24 +02: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
Niels Dossche
d11f9717fd
zend_alloc: Fix compile with ZEND_MM_STAT=0
Closes GH-18811.
2025-06-09 17:27:39 +02:00
Niels Dossche
186a8116be
Fix test conflict between copy_variation2-win32-mb.phpt and copy_variation2-win32.phpt
Closes GH-18809.
2025-06-09 14:16:18 +02:00
Niels Dossche
b3c8afe272
Fix GH-18743: Incompatibility in Inline TLS Assembly on Alpine 3.22
GAS started checking the relocation for tlsgd: it must use the %rdi
register. However, the inline assembly now uses %rax instead.
Fix it by changing the "=a" output register to "=D".
Source: ec181e1710/gas/config/tc-i386.c (L6793)

gottpoff is unaffected.

Closes GH-18779.
2025-06-09 11:39:34 +02:00
Niels Dossche
786090b35d
pdo_odbc: Fix memory leak if WideCharToMultiByte() fails
Closes GH-18788.
2025-06-09 11:24:48 +02:00
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