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

69571 Commits

Author SHA1 Message Date
Michael Orlitzky
3053a039ff ext/dba/tests/dba_db4_018.phpt: fix typo (#20938)
We expect "objects" but print "object".

Gentoo-bug: https://bugs.gentoo.org/968656
2026-01-24 11:38:45 +00: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
Ilija Tovilo
4367315183 [skip ci] Reduce zend.max_allowed_stack_size in gh20840.phpt
This test still fails on i386 Windows with "Allowed memory size of %d bytes
exhausted" because the output buffer grows too big. My first intuition was to
add a chunk_size to ob_start, but this won't work if the output buffer is
flushed deep into the call stack, causing a premature or just a second stack
limit error. So, reduce the stack size in an attempt to produce less output.
2026-01-21 17:32:01 +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
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
Peter Kokot
c4084bb8f3 Use PHP 8+ square brackets for array elements
The curly braces syntax for array elements has been removed in PHP 8.0.
2026-01-18 17:58:00 +01:00
Ilija Tovilo
462fcad419 Avoid huge output in gh20840.phpt
This can trigger the memory limit in run-tests.php, which buffers the tests
output. Instead, only output "nesting level too deep" and discard the rest.

Closes GH-20946
2026-01-16 13:03:53 +01:00
Bob Weinand
27ed48c0be Split the live-ranges of loop variables again (#20865)
* Fix use-after-free in FE_FREE with GC interaction

When FE_FREE with ZEND_FREE_ON_RETURN frees the loop variable during
an early return from a foreach loop, the live range for the loop
variable was incorrectly extending past the FE_FREE to the normal
loop end. This caused GC to access the already-freed loop variable
when it ran after the RETURN opcode, resulting in use-after-free.

Fix by splitting the ZEND_LIVE_LOOP range when an FE_FREE with
ZEND_FREE_ON_RETURN is encountered:
- One range covers the early return path up to the FE_FREE
- A separate range covers the normal loop end FE_FREE
- Multiple early returns create multiple separate ranges

* Split the live-ranges of loop variables again

b0af9ac733 removed the live-range splitting of foreach variables, however it only added handling to ZEND_HANDLE_EXCEPTION.
This was sort-of elegant, until it was realized in 8258b7731b that it would leak the return variable, requiring some more special handling.
At some point we added live tmpvar rooting in 52cf7ab8a2, but this did not take into account already freed loop variables, which also might happen during ZEND_RETURN, which cannot be trivially accounted for, without even more complicated handling in zend_gc_*_tmpvars() functions.

This commit also proposes a simpler way of tracking the loop end in loopvar freeing ops: handle it directly during live range computation rather than during compilation, eliminating the need for opcache to handle it specifically.
Further, opcache was using live_ranges in its basic block computation in the past, which it no longer does. Thus this complication is no longer necessary and this approach should be actually simpler now.

Closes #20766.

Signed-off-by: Bob Weinand <bobwei9@hotmail.com>

---------

Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
Co-authored-by: Gustavo Lopes <mail@geleia.net>
2026-01-15 16:13:43 +01:00
Alexandre Daubois
2c112e3696 Fix GH-20836: Stack overflow in mb_convert_variables with recursive array references (#20839) 2026-01-14 20:07:11 +01:00
Derick Rethans
c929f2aa87 Update generated parser file 2026-01-14 14:21:29 +00:00
Derick Rethans
9d4a1f0c7e Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Upgrade timelib to 2022.16
2026-01-14 14:11:29 +00:00
Derick Rethans
e208cd86b4 Upgrade timelib to 2022.16 2026-01-14 14:10:44 +00:00
Derick Rethans
65e316e89c Updated to version 2025.3 (2025c) 2026-01-14 13:55:15 +00:00
Derick Rethans
2670c8646d Updated to version 2025.3 (2025c) 2026-01-14 13:55:08 +00:00
Arnaud Le Blanc
075b6b85f6 Set default_object_handlers when registering internal enums
Internal enums can be cloned and compared, unlike user enums, because we didn't set default_object_handlers when registering internal enums.

Fix by setting default_object_handlers when registering internal enums.

Fixes GH-20914
Closes GH-20915
2026-01-13 12:32:52 +01:00
Niels Dossche
1052270001 Add test for GH-20880 (#20919)
Closes GH-20880.
2026-01-12 22:45:24 +01:00
Dmitry Stogov
098b1f89bd Update IR (#20916)
IR commit: 40cd6ad28c376cf006c360f39d8aeff6d6e7bf78
2026-01-12 21:23:38 +03:00
Niels Dossche
290ebf13e1 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix bug52820 test for new libcurl release
2026-01-12 18:47:51 +01:00
Niels Dossche
39da78f422 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix bug52820 test for new libcurl release
2026-01-12 18:47:45 +01:00
Niels Dossche
636f84adcf Fix bug52820 test for new libcurl release
Reference: GH-20910.
2026-01-12 18:47:33 +01:00
Niels Dossche
2a2e0e8128 Fix GH-20856: heap-use-after-free in SplDoublyLinkedList iterator when modifying during iteration
The element may be still in use in other places, so the linking pointers
should be kept consistent. If not consistent, the "move forward" code in
the sample test will read a stale, dangling pointer.

Closes GH-20885.
2026-01-11 20:42:25 +01:00
Ilija Tovilo
f61b1fc036 Fix block_pass JMP[N]Z optimization
In the following optimization:

JMPZ(X,L1) JMP(L2) L1: -> JMPNZ(X,L2) NOP

L1 must not be followed by another block, so that it may safely be followed by
the block containing the JMPNZ. get_next_block() is used to verify L1 is the
direct follower. This function also skips empty blocks, including live, empty
target blocks, which will then implicitly follow the new follow block. This will
result in L1 being followed by two separate blocks, which is not possible.

Resolve this by get_next_block() stopping at target blocks.

Fixes OSS-Fuzz #472563272
Closes GH-20850
2026-01-11 14:55:23 +01:00
Niels Dossche
a6e0d8e359 Fix GH-20882: phar buildFromIterator breaks with missing base directory
Broke in f57526a07a because of changing a char*+size_t pair to
zend_string* (which can't handle NULL pointers in its macros).

Closes GH-20888.
2026-01-10 15:09:36 +01:00
David Carlier
5d2456f974 Fix GH-20840: crash on nested object with var_dump().
mitigate it with stack check limit.

close GH-20843
2026-01-09 18:13:42 +00:00
Ilija Tovilo
226f68b24f Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  [skip ci] Mark bug69442.phpt (PTY test) as flaky
2026-01-08 12:27:06 +01:00
Ilija Tovilo
33c3e30ed6 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [skip ci] Mark bug69442.phpt (PTY test) as flaky
2026-01-08 12:27:00 +01:00
Ilija Tovilo
4f25ea88f0 [skip ci] Mark bug69442.phpt (PTY test) as flaky
See GH-20864
2026-01-08 12:26:20 +01:00
Frank Denis
83f3d5d487 ext/sodium: use correct constants and error messages (#20852)
Fix copy-and-paste mistakes in the sodium extension.

crypto_scalarmult_BYTES and crypto_scalarmult_ristretto255_BYTES
have the same value, so behavior is unchanged.
2026-01-07 09:45:06 +01:00
Niels Dossche
03113b09ce Fix GH-20833: mb_str_pad() divide by zero if padding string is invalid in the encoding
If the padding string is not valid in the given encoding,
mb_get_strlen() can return 0.

Closes GH-20834.
2026-01-05 20:01:25 +01:00
Jakub Zelenka
91ac825278 Fix bug #74357: lchown fails to change ownership of symlink with ZTS 2026-01-03 14:41:57 +01:00
Niels Dossche
30ed81314b Fix GH-18139: Memory leak when overriding some settings via readline_info()
The reason why freeing was not done yet is because the pointer in these
variables may be:
- Static data set by the readline/libedit library initially, not heap
  data.
- Data set by another thread. Although the libraries appear to be not
  thread-safe anyway.

To solve this, introduce some TLS variables to hold a pointer for us
when we override the settings, such that we can free them and are
certain they are allocated by us.

Closes GH-20794.
2026-01-02 13:04:13 +01:00
David Carlier
cdcc0c2cd8 Fix GH-20802: undefined behavior with invalid SNI_server_certs options.
close GH-20803
2026-01-01 21:08:35 +00:00
Calvin Buckley
6ceb887dc2 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix skipif for mkfifo usage in gh20582.phpt (#20804)
2025-12-31 13:05:27 -04:00
Calvin Buckley
bd484ed65f Fix skipif for mkfifo usage in gh20582.phpt (#20804)
Makes it like ext/standard/tests/file/filetype_variation.phpt; it's not
just Windows that can have a missing posix_mkfifo, but also a minimal
build, like the ones suggested that RMs test with (using --disable-all).
2025-12-31 13:04:09 -04:00
Niels Dossche
29e04acc6f Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-19962: arrayIndexThenCheck static analysis warning in firebird
2025-12-28 13:09:05 +01:00
Niels Dossche
bae78c614a Fix GH-19962: arrayIndexThenCheck static analysis warning in firebird
Same as ce534c612b.
2025-12-28 13:08:40 +01:00
Niels Dossche
fa8bb98ec0 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-19961: Static analysis arrayIndexThenCheck warning in firebird (#20790)
2025-12-28 13:04:27 +01:00
Niels Dossche
ce534c612b Fix GH-19961: Static analysis arrayIndexThenCheck warning in firebird (#20790)
Static analysis reports that the bounds check comes after reading the
byte from the buffer.
In practice, this is tagged data that loops until the end tag is found
and therefore there isn't really a bug. The extra length check is only
there for extra hardening.
So we simply silence the static analysers and improve the hardening.

See also https://docwiki.embarcadero.com/InterBase/15/en/Isc_dsql_sql_info()
2025-12-28 13:04:16 +01:00
Niels Dossche
dabcd74524 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix OOB gzseek() causing assertion failure
2025-12-28 00:21:56 +01:00
Niels Dossche
2709ebc0ce Fix OOB gzseek() causing assertion failure
Closes GH-20785.
2025-12-28 00:21:32 +01:00
Niels Dossche
48b4289dff Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-20582: Heap Buffer Overflow in iptcembed
2025-12-26 22:44:14 +01:00
Niels Dossche
99ed66b49f Fix GH-20582: Heap Buffer Overflow in iptcembed
If you can extend the file between the file size gathering (resulting in
a buffer allocation), and reading / writing to the file you can trigger a
TOC-TOU where you write out of bounds.
To solve this, add extra bound checks and make sure that write actions
always fail when going out of bounds.
The easiest way to trigger this is via a pipe, which is used in the
test, but it should be possible with a regular file and a quick race
condition as well.

Closes GH-20591.
2025-12-26 22:43:45 +01:00
Niels Dossche
40c291cf93 Fix GH-20444: Dom\XMLDocument::C14N() seems broken compared to DOMDocument::C14N()
C14N code expects namespace to be in-tree, but we store namespaces in a
different way out-of-tree to avoid reconciliations that break the tree
structure in a way unexpected by the DOM spec. In the DOM spec,
namespace nodes don't exist; they're regular attributes.
To solve this, we temporarily make fake namespace nodes that we later
remove.

Closes GH-20457.
2025-12-26 22:27:25 +01:00
Gina Peter Banyard
20f9772063 ext/standard: Fix memory leak in mail() when header key is numeric
Closes GH-20776
2025-12-25 19:42:31 +01:00
David Carlier
5faa54d93b ext/pcntl: fix pcntl_getcpuaffinity() for solaris.
trusting the call to handle invalid process id via errnos.

see https://github.com/php/php-src/pull/20709#discussion_r2630221301 for
rationale.

close GH-20731
2025-12-24 16:10:13 +00:00
Niels Dossche
8c860ce66e [ci skip] Add missing EXTENSIONS dependency to test 2025-12-23 11:27:34 +01:00