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

17407 Commits

Author SHA1 Message Date
David Carlier
1b61d555fb ext/soap: Fix wrong cookie options offset calculation, using separator offset instead.
The cookie option parser uses a wrong offset to start scanning
attributes, causing cookie values containing substrings like
"path=" or "domain=" to be falsely matched as attributes.

close GH-21400
2026-03-10 21:58:52 +00:00
ndossche
ea8aab9220 Fix memory leak in shm_get_var() when variable is corrupted
This path wasn't tested (clearly).
To trigger this we use FFI, which seemed like the easiest way that
doesn't involve using another process messing with the shared memory.

Closes GH-21388.
2026-03-10 20:30:02 +01:00
ndossche
3073948885 Revert "ext/session: Fix memory leak due to multiple exception happening during session abort"
This reverts commit 0acde11945.

The patch is incorrect as described in GH-21200 in the post-merge
comments.
2026-03-10 20:28:47 +01:00
武田 憲太郎
35d98cb6ce ext/pgsql: Fix preprocessor guard typo that silently disabled a feature
Fix `PQTRACE_SUPPRESS_TIMESTAMPS` guard misspelling in pgsql.stub.php.

The guard has been misspelled as `PQTRACE_SUPPPRESS_TIMESTAMPS`
(three P's) since 7ec8ae12c4, preventing the
`PGSQL_TRACE_SUPPRESS_TIMESTAMPS` constant from being registered.

close GH-21386
2026-03-09 07:41:04 +00:00
Gina Peter Banyard
0acde11945 ext/session: Fix memory leak due to multiple exception happening during session abort
Closes GH-21200

Co-authored-by: arshidkv12 <arshidkv12@gmail.com>
2026-03-07 13:28:42 +00:00
Yannis
c3777c73b3 Update ext/standard/libavifinfo
Fixes GH-20627.
Closes GH-21250.
2026-03-07 11:17:56 +01:00
David Carlier
41458c6ad6 Fix GH-21336: undefined behavior in snmp setSecurity.
close GH-21337
2026-03-05 18:48:39 +00:00
Niels Dossche
4ee95fc2f3 bz2: Fix truncation of total output size causing erroneous errors
Also switch to uint64_t as that's used on master and makes the code
simpler to fix.

Closes GH-20807.

Co-authored-by: Arnaud Le Blanc <arnaud.lb@gmail.com>
2026-02-27 23:46:48 +01:00
David Carlier
f8114f554c ext/pcre: fix mdata_used race conditions in PCRE functions
Mirror the mdata_used protection pattern from php_pcre_replace_func_impl
in php_pcre_match_impl, php_pcre_replace_impl, php_pcre_split_impl,
and php_pcre_grep_impl.

close GH-21291
2026-02-27 22:14:41 +00:00
ndossche
1709689256 Fix GH-20906: Assertion failure when messing up output buffers
Closes GH-20908.
2026-02-27 18:14:56 +01:00
David Carlier
78702fa470 ext/pcre: fix memory leaks on error paths
Fix pcre2_code leak when pcre2_pattern_info() fails after a successful
pcre2_compile(), and fix match_sets/match_data/marks leak when
offsets[1] < offsets[0] in php_pcre_match_impl().

close GH-21298
2026-02-26 18:56:24 +00:00
Calvin Buckley
9942f063db PHP-8.4 is now for PHP 8.4.20-dev 2026-02-24 17:50:02 -05:00
David Carlier
6c45f7a000 ext/pcre: preg_match() fix memory leak with invalid regexes.
close GH-21290
2026-02-24 22:19:27 +00:00
Ilija Tovilo
ec5a1e001d Fix preloaded constant erroneously propagated to file-cached script
Since GH-15021 preloaded constants are propagated to compiled scripts. This is
problematic for file cache, which assumes all referenced zvals are either
persistently allocated or local to the current script. However, preloaded
constants live in shm as immutable, but not persistent.

To solve this, we'd need to duplicate propagated constants in the optimizer when
file cache is used. This is error prone given it needs to happen in many places.
It's debatable whether constant propagation is even correct in this case, as
running the preloaded script on a restart isn't guaranteed to produce the same
result.

Hence, avoid the issue for now by just not relying on preloaded symbols when
file cache is used.

Fixes GH-21052
Closes GH-21281
2026-02-24 17:28:56 +01:00
David Carlier
296fad10fb ext/pcntl: fix pcntl_signal_dispatch() stale tail pointer and exception handling.
close GH-21259
2026-02-23 21:24:38 +00:00
Michael Orlitzky
db6cca26dd sapi/*/Makefile.frag: install programs built with libtool, with libtool
When installing executables that were built using libtool, we are
supposed to use

  $ libtool --mode-install <install-command>

rather than the bare <install-command>. This is discussed ever so
briefly in the "Installing executables" section of the GNU libtool
documentation:

  https://www.gnu.org/software/libtool/manual/libtool.html

So far this has not caused a problem with GNU libtool on the platforms
that PHP supports, but there is an alternate libtool implementation
called slibtool that stores wrappers at the locations where PHP is
expecting the true executables to live. As a result, the wrappers (and
not the executables) are installed when slibtool is used to build PHP.

This is fixed by replacing,

  $(INSTALL)

with

  $(LIBTOOL) --mode=install $(INSTALL)

in the install-foo rules for the executables that are built with
libtool.

Closes GH-13674
2026-02-23 17:19:23 +01:00
David Carlier
6a1bde5d38 ext/pcntl: Fix signal table updated before php_signal4 succeeds in pcntl_signal
Move the signal table update after the php_signal4 call, mirroring
what is already done in the SIG_DFL/SIG_IGN (integer) code path.
This prevents a stale entry in the table if sigaction fails.

close GH-21270
2026-02-23 12:47:55 +00:00
David Carlier
37ce67f276 ext/pcntl: Fix cpuset leak in pcntl_setcpuaffinity on out-of-range CPU ID
Add missing PCNTL_CPU_DESTROY(mask) call before RETURN_THROWS() when
the cpu id is out of range, matching the cleanup on other error paths.

close GH-21268
2026-02-22 19:57:19 +00:00
David Carlier
e2a5909ba3 ext/pcntl: fix pcntl_setns() error handling.
Save errno into a local int before calling close(fd), as close() may
clobber errno on failure. Use int rather than errno_t because errno_t
is defined in C11 Annex K (bounds-checking interfaces) which is
optional and not widely implemented — many platforms (Linux/glibc,
musl, macOS, FreeBSD) do not provide it.

close GH-21256
2026-02-22 19:05:55 +00:00
Niels Dossche
e2059a4697 curl: Don't truncate length
Truncating to an int seems dangerous, esp. in combination with a MIN
macro. I don't see a reason to truncate the length from size_t to int,
and especially no reason to change the signedness.

Closes GH-20747.
2026-02-17 23:15:55 +01:00
ndossche
b911748fef Update NEWS for OpenSSL changes 2026-02-17 21:40:24 +01:00
Ilija Tovilo
1931472f22 Fix borked SCCP of array containing partial object
In SCCP, arrays containing partial objects must be marked as partial so that
their values are not accidentally propagated.

Fixes GH-21227
Closes GH-21232
2026-02-17 18:11:28 +01:00
Jordi Kroon
37c5a13d67 replace alloca with do_alloca in mb_guess_encoding_for_strings
This avoids a crash in cases where the list of candidate encodings is so huge
that alloca would fail. Such crashes have been observed when the list of
encodings was larger than around 208,000 entries.
2026-02-17 06:46:42 +09:00
Arnaud Le Blanc
ede7c67389 Fix build with -std=
When building in strict mode (e.g. -std=c11), compilation of
main/debug_gdb_scripts.c fails because asm() is not a standard top level
statement. __asm__() however can be reserved by the compiler even in strict
mode.

Partially fixes GH-21215. IR needs a similar fix (dstogov/ir#128).
Closes GH-21226.
2026-02-16 14:48:48 +01:00
David Carlier
b6495c189a ext/sockets: socket_sendto() add max addr length control for AF_UNIX.
we just mirror what is done for socket_connect()/AF_UNIX type.

close GH-21218
2026-02-15 21:54:19 +00:00
David Carlier
539c5d9f76 Fix GH-21162: pg_connect() on error memory leak.
The PHP_PQ_ERROR macro calls php_error_docref() which triggers user error handlers
thus libpq does not have the chance to clean the resources (and empty
connections string are allowed) on failure thus we avoid this macro
and delay the error handling after.

close GH-21165
2026-02-15 21:26:23 +00:00
David Carlier
19ee3e6697 Fix GH-21161: socket_set_option() crash with array 'addr' entry as null.
in the ipv6 address creation helper we need to use, for the error
message, the converted data rather than assuming the original
is a proper zend_string().

close GH-21166
2026-02-09 19:26:48 +00:00
Petr Sumbera
7c6f08945f Improve shared_alloc_shm.c strategy to support OPcache JIT on Solaris
The SysV shared memory allocator in OPcache hardcodes a maximum segment size of
32MB (SEG_ALLOC_SIZE_MAX). If the JIT buffer exceeds this, which it does with
the default 64MB size, startup will fail with "Insufficient shared memory!".

The allocator will now try allocating a contiguous buffer first, and only then
use segmentation by searching for continuously smaller powers of 2.

Fixes GH-20718
Closes GH-20719
2026-02-09 14:58:13 +01:00
Niels Dossche
ee26417b58 Fix timezone offset with seconds losing precision
There are two issues:
1. The 'e' formatter doesn't output the seconds of the timezone even if
   it has seconds.
2. var_dump(), (array) cast, serialization, ... don't include the
   timezone second offset in the output. This means that, for example,
   serializing and then unserializing a date object loses the seconds of
   the timezone. This can be observed by comparing the output of
   getTimezone() for `$dt` vs the unserialized object in the provided test.

Closes GH-20764.
2026-02-05 18:38:54 +01:00
Ilija Tovilo
3cb85cc681 Fix assign-op/inc/dec on untyped hooked property backing value
Fixes OSS-Fuzz #478009707
Closes GH-21124
2026-02-05 14:46:06 +01:00
Niels Dossche
7445b0f6d9 Fix GH-20936: DatePeriod::__set_state() cannot handle null start
The "current" and "end" field also rely on start_ce, which is set by
"start". Therefore, if "current" or "end" are provided, so must "start"
be provided.

Closes GH-20939.
2026-02-04 18:34:38 +01:00
Niels Dossche
b8fc6bd1c8 Fix GH-21097: Accessing Dom\Node properties can can throw TypeError(s)
Split the handler again, or defer to instanceof when performance doesn't
matter.

Closes GH-21108.
2026-02-03 18:36:28 +01:00
Arnaud Le Blanc
de26827275 Real instance of lazy proxy may have less magic methods
In GH-18039 we guard the underlying property before forwarding access
to the real instance of a lazy proxy. When the real instance lacks magic
methods, the assertion zobj->ce->ce_flags & ZEND_ACC_USE_GUARDS fails in
zend_get_property_guard().

Fix by checking that the real instance uses guards.

Fixes GH-20504
Closes GH-21093
2026-02-03 12:04:35 +01:00
Arnaud Le Blanc
6d6d013d79 Mark object non-lazy before deleting info in zend_lazy_object_realize()
A lazy object is marked non-lazy when all its properties are
initialized. Before doing so we delete the object info, resulting in a
temporarily invalid state. In GH-20657 the GC is triggered at this moment.

Fix by deleting the object info _after_ marking it non lazy.

Fixes GH-20657
Closes GH-21094
2026-02-03 11:48:36 +01:00
Niels Dossche
d73b2f782e Fix GH-21077: Accessing Dom\Node::baseURI can throw TypeError
Prior to this patch there was a common read handler, and it relied on
the dom class set in the intern document. However, Dom\Implementation
allows creating DTDs unassociated with a document, so we can't rely on
an intern document and the check fails. This causes the ZVAL_NULL() path
to be taken.
To solve this, just split the handler.

Closes GH-21082.
2026-01-30 18:13:55 +01:00
David Carlier
b156471a30 Fix GH-21023: CURLOPT_XFERINFOFUNCTION with invalid callback crash.
we check the FCC is properly initialised beforehand in its handler.

close GH-21025
2026-01-30 13:09:44 +00:00
Kévin Dunglas
371422b9b9 Zend/zend_call_stack.h: fix missing include on Windows (clang compat) (#20847)
Co-authored-by: Tim Düsterhus <tim@tideways-gmbh.com>
2026-01-29 10:38:10 +01:00
Loïc Saos
3037526810 Fix GH-21055: Pdo/Pgsql typo for GSS negotiation connection status attribute.
close GH-21057
2026-01-28 18:12:08 +00:00
Arnaud Le Blanc
93d32eae27 Add missing clobbered registers
Inline assembly in zend_safe_address() clobbers flags register. Add missing
register in clobber list for aarch64 and powerpc64. Other archs were already
correct.

Fixes GH-21029
2026-01-28 18:20:07 +01:00
Saki Takamachi
e6beffb6ed PHP-8.4 is now for PHP 8.4.19-dev 2026-01-27 22:21:42 +09:00
Alexander Borisov
56e5a80c44 Fix GH-21041: Dom\HTMLDocument corrupts closing tags within scripts 2026-01-26 19:20:10 +01:00
Niels Dossche
62afc7a2fa Fix crash in openssl_x509_parse() when X509_NAME_oneline() fails
The X509_NAME_oneline() function can return NULL, which will cause a
crash when the string length is computed via add_assoc_string().

Closes GH-21010.
2026-01-23 14:59:08 +01:00
Niels Dossche
c2eadb4922 Fix crash when in openssl_x509_parse() when i2s_ASN1_INTEGER() fails
The X509_NAME_oneline() function can return NULL,
which will cause a crash when the string length is computed via add_assoc_string().

Closes GH-21011.
2026-01-23 14:58:39 +01:00
Niels Dossche
7754eafb1f Fix memory leaks when sk_X509_new_null() fails
In a lot of places the return value is not checked, and when the
function fails the code continues execution. However, this means that
operations on the stack fail and will cause memory leaks on the objects
that weren't pushed.

We also notice an inconsistency in how these failures are handled.
For example, in one place we explicitly have a fatal error
`php_error_docref(NULL, E_ERROR, "Memory allocation failure");`
but this is the only place to do so.

Closes GH-20957.
2026-01-22 22:37:14 +01:00
Niels Dossche
d9cbc3117c Fix hooked object properties overflow
The computed number of properties using zend_hash_num_elements(zobj->properties)
is incorrect when the object contains virtual properties. We don't have a
trivial way to find the number of properties virtual properties that need to be
added to this number, so just append with zend_hash_add_new() instead.

Fixes GH-20479
Closes GH-20988
2026-01-21 18:53:41 +01:00
Chris Hasiński
1db1c7f5c1 Fix segfault in Tracing JIT with object reference (GH-20818)
When FE_RESET_RW executes, it converts the CV to a reference before
checking if the array/object is empty. However, when the JIT creates
exit points for FE_RESET_RW in zend_jit_trace_handler(), it wasn't
updating the stack type for op1 to reflect this change.

This caused side traces compiled from these exit points to have
incorrect type information. The side trace's CV cleanup code would
see IS_OBJECT and generate a direct call to zend_objects_store_del(),
but the actual value was a zend_reference*, causing a segfault.

The fix adds ZEND_FE_RESET_RW to the list of opcodes that temporarily
set their op1 stack type to IS_UNKNOWN before creating exit points.
This follows the same pattern used for ZEND_BIND_INIT_STATIC_OR_JMP.
When IS_UNKNOWN, the JIT falls back to SSA type info which correctly
includes MAY_BE_REF for FE_RESET_RW's op1_def.

Fixes GH-20818
Closes GH-20948
2026-01-21 00:24:14 +01:00
Niels Dossche
32c0245531 Revert "Fix GH-20890: Segfault in zval_undefined_cv with non-simple property hook with minimal tracing JIT"
This reverts commit 57c62eb2b3.
2026-01-20 21:05:26 +01:00
Niels Dossche
57c62eb2b3 Fix GH-20890: Segfault in zval_undefined_cv with non-simple property hook with minimal tracing JIT
This is similar to f6c2e40a11 but for minimal JIT + tracing JIT.
Most of the times the tracing JIT shouldn't rely on going to the VM, but
in some cases, like in minimal JIT, it can and then it hits the same
bug.

Closes GH-20897.
2026-01-20 18:55:08 +01:00
Ilija Tovilo
f38f74521b Fix lazy proxy bailing __clone assertion
When __clone of the underlying object fails with a bailout, ZEND_ASSERT(res ==
SUCCESS) in zend_lazy_object_del_info() will fail because the info has not been
registered yet.

Only copy OBJ_EXTRA_FLAGS once the info has been successfully registered.

Fixes GH-20905
Closes GH-20975
2026-01-20 17:58:56 +01:00
David Carlier
5785ff7728 exp/pgsql: insert/update query string build possible UB fix.
From PQescapeIdentifier() docs

```
A terminating zero byte is not required, and should not be counted in
length
```
2026-01-19 06:17:23 +00:00