1008 Commits
Author SHA1 Message Date
Jorg Sowa 0220731872 Merge branch 'PHP-8.6'
# Conflicts:
#	NEWS
2026-10-23 08:27:34 +02:00
Jorg Sowa 644b5e8896 Merge branch 'PHP-8.5' into PHP-8.6 2026-10-23 08:27:33 +02:00
Jorg Sowa 9da174f52a Merge branch 'PHP-8.4' into PHP-8.5 2026-10-23 08:27:28 +02:00
Jorg Sowa f6852befa3 ext/mbstring: fix over-read in php_mb_rfc1867_getword()
A multibyte lead byte at the end of a multipart field name made the
scan advance by the full character width past the terminating NUL,
reading out of bounds. Advance byte by byte and stop at the
terminator in both advance sites, as php_mb_rfc1867_substring_conf()
already does.

Closes GH-24498
2026-10-23 08:27:24 +02:00
Ilija Tovilo 9705fda1bb Merge branch 'PHP-8.6' into master
* PHP-8.6:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:34:56 +02:00
Ilija Tovilo d6373dfe15 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:33:23 +02:00
Ilija Tovilo c7273b9ba8 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:30:04 +02:00
Ilija Tovilo 8a94bb3822 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:27:03 +02:00
Ilija Tovilo c1a5f468d0 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Add NEWS entry
  Avoid state corruption via bailout
2026-10-21 16:12:35 +02:00
3584a98bda Avoid state corruption via bailout
- Replace bailout on OOM with UnwindExit
- Properly reset various globals that may be accessed during startup

Fix GHSA-w8hw-w9fx-j79w (CVE-2026-109618)
Fix GHSA-6wmf-4rv5-p3rp (CVE-2026-109619)

Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
Co-authored-by: Jakub Zelenka <bukka@php.net>
Co-authored-by: Nora Dossche <7771979+ndossche@users.noreply.github.com>
Co-authored-by: Nicolas Grekas <nicolas.grekas@gmail.com>
2026-10-21 16:06:22 +02:00
Kamil Tekiela f9cf4fb51b Merge branch 'PHP-8.5' into PHP-8.6 2026-10-12 14:34:10 +01:00
Kamil Tekiela 8cc6af86a6 Merge branch 'PHP-8.4' into PHP-8.5 2026-10-12 14:33:25 +01:00
Kamil Tekiela 5838b68a14 ext/mbstring: Fix truncated encoding names resolving to full names (#23974)
Closes GH-23958
2026-10-12 14:26:46 +01:00
Alex Dowad c150ed11da Merge branch 'PHP-8.5' into PHP-8.6 2026-09-28 21:52:05 +09:00
Alex Dowad b7b493bf6f Merge branch 'PHP-8.4' into PHP-8.5 2026-09-28 21:49:02 +09:00
Nicolas Grekas 0cf8668eb2 ext/mbstring: Don't emit surrogates when encoding to UTF-8
The UTF-8 encoder turned surrogate codepoints into 3-byte sequences like
"\xED\xA0\x80", which are not valid UTF-8. Such codepoints come from
UCS-2, UCS-4 or HTML-ENTITIES input, or from mb_decode_numericentity().
Since mbstring marks the UTF-8 strings it returns as valid UTF-8,
functions that trust that flag, like mb_check_encoding(), mb_scrub() or
preg_match(), accepted them too.

Surrogates are now replaced by the substitute character, as codepoints
above U+10FFFF already are. The internal mode used by mb_strpos() and
similar functions still encodes them, so that different surrogates don't
match each other.
2026-09-28 21:48:40 +09:00
Ilija Tovilo 87d4e0a2de Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  [skip ci] Fix mb_ereg_replace_kname_unterminated_nul.phpt SKIPIF
2026-09-25 17:10:52 +02:00
Ilija Tovilo d8f5f6acc5 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  [skip ci] Fix mb_ereg_replace_kname_unterminated_nul.phpt SKIPIF
2026-09-25 17:10:42 +02:00
Ilija Tovilo ead145b4ba [skip ci] Fix mb_ereg_replace_kname_unterminated_nul.phpt SKIPIF
mbregex is not always available.
2026-09-25 17:08:49 +02:00
tekimen cc781b9c65 ext/mbstring: Update to Unicode 18.0 (#23755)
* ext/mbstring: Update to Unicode 18.0

Previously:
 - https://github.com/php/php-src/pull/15898
 - 0fdffc1807
 - https://github.com/php/php-src/pull/7502
 - https://github.com/php/php-src/pull/14680

* Update NEWS and UPGRADING
2026-09-19 09:20:53 +09:00
Weilin Du 063d787542 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix GH-23106: mb_strpos() overreads truncated UTF-8 haystacks (#23107)
2026-09-12 14:32:08 +08:00
Weilin Du 35889a78d8 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-23106: mb_strpos() overreads truncated UTF-8 haystacks (#23107)
2026-09-12 14:29:29 +08:00
lazerg cc22056f9d Fix GH-23106: mb_strpos() overreads truncated UTF-8 haystacks (#23107)
offset_to_pointer_utf8() walks the haystack using the UTF-8 mblen table.
For a truncated multibyte sequence, the lead byte's table entry can exceed
the remaining bytes and leave the search start pointer past the end.

Passing that pointer to zend_memnstr() triggers an assertion in debug
builds and an out-of-bounds read in release builds, producing bogus
offsets or a crash for sufficiently long haystacks.

Clamp the pointer to the end of the string, as mb_str_split() already does
for the same table walk. Add regression coverage for forward and reverse
searches, negative offsets, and offsets beyond the haystack.

Fixes GH-23106.

Closes #23107
2026-09-12 14:27:13 +08:00
Ilia Alshanetsky 2d7131e1bf Merge branch 'PHP-8.5'
* PHP-8.5:
  [mbstring] Fix mb_ereg_replace() emitting NUL/garbage for unterminated \k<name>
2026-09-01 08:58:23 -04:00
Ilia Alshanetsky cb1b529fc3 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  [mbstring] Fix mb_ereg_replace() emitting NUL/garbage for unterminated \k<name>
2026-09-01 08:57:56 -04:00
Ilia Alshanetsky 509e27bae1 [mbstring] Fix mb_ereg_replace() emitting NUL/garbage for unterminated \k<name>
When a \k<name> backref in an mb_ereg_replace() replacement string lacks
its closing delimiter, the error path computed p = name_end + 1 past eos
and copied the trailing NUL terminator into the output; the multibyte
sibling path (p += clen after \k) could overshoot eos and read heap bytes
past the string. Both paths are now clamped to eos so verbatim fallback
never copies beyond the parsed name.

Closes GH-23499
2026-09-01 08:57:37 -04:00
Gina Peter Banyard 7cc143235d mbstring: deprecate passing objects as vars to mb_convert_variables()
RFC: https://wiki.php.net/rfc/deprecations_php_8_6#passing_objects_for_vars_parameter_of_mb_convert_variables
2026-08-10 18:21:19 +01:00
tekimen 0d9b381beb Update ext/mbstring/tests/gh21036.phpt 2026-08-01 12:02:14 +09:00
Matthias Goergens efd178b1b6 Fix mbregex search state after cache invalidation
Closes GH-22954
2026-08-01 12:02:14 +09:00
tekimen f699538427 Update ext/mbstring/tests/gh21036.phpt 2026-08-01 12:01:59 +09:00
Matthias Goergens da4b676047 Fix mbregex search state after cache invalidation
Closes GH-22954
2026-08-01 12:01:58 +09:00
tekimen 0ee81b4060 Update ext/mbstring/tests/gh21036.phpt 2026-08-01 12:01:43 +09:00
Matthias Goergens 03a71535c3 Fix mbregex search state after cache invalidation
Closes GH-22954
2026-08-01 12:01:36 +09:00
NickSdot 7b78eb4fcc ext/mbstring: applied fixers to improve test robustness 2026-07-31 08:31:55 +09:00
Alex Dowad 4983e8bb44 Merge branch 'PHP-8.5' 2026-07-23 14:54:14 +09:00
Alex Dowad e0a9940134 Merge branch 'PHP-8.4' into PHP-8.5 2026-07-23 14:53:28 +09:00
Eyüp Can Akman 0d6ab5321d Fix GH-22779: mb_strrpos() wrong result in a non-UTF-8 encoding
mb_find_strpos() converts the haystack and needle to UTF-8 and does the length and offset math on the converted strings.
The negative-offset branch computed the needle length from the raw needle instead of needle_u8.
mb_fast_strlen_utf8() reads those bytes as UTF-8, so the count is wrong whenever they do not decode one to one.
A byte in 0x80-0xBF (ISO-8859-1) undercounts, and a wider encoding such as an ASCII needle in UTF-16 overcounts, so the reverse-search window is shifted.
Use needle_u8, the converted needle the rest of the branch already searches with.
2026-07-23 14:52:15 +09:00
Ilija Tovilo 388f30769f Merge branch 'PHP-8.5'
* PHP-8.5:
  GHSA-74r9-qxhc-fx53: [mbstring] Fix out-of-bounds access in mbfl_name2encoding_ex()
2026-05-06 13:13:29 +02:00
Ilija Tovilo f30cb4409a Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  GHSA-74r9-qxhc-fx53: [mbstring] Fix out-of-bounds access in mbfl_name2encoding_ex()
2026-05-06 13:13:10 +02:00
Ilija Tovilo 56ee76f820 GHSA-74r9-qxhc-fx53: [mbstring] Fix out-of-bounds access in mbfl_name2encoding_ex()
Fixes GHSA-74r9-qxhc-fx53
Fixes CVE-2026-6104
2026-05-06 13:13:05 +02:00
tekimenandTim Düsterhus cc56225339 [RFC][mbregex] Set deprecate Oniguruma(mbregex) (#21490)
Set deprecate Oniguruma(mbregex)

Thank you for Oniguruma.

Co-authored-by: Tim Düsterhus <timwolla@googlemail.com>
2026-04-28 11:06:53 +09:00
Alex Dowad 115ea486ac Merge branch 'PHP-8.5' 2026-02-17 06:51:21 +09:00
Alex Dowad e106d688c2 Merge branch 'PHP-8.4' into PHP-8.5 2026-02-17 06:48:37 +09: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
Ilija Tovilo cb51737f41 Merge branch 'PHP-8.5'
* PHP-8.5:
  Tweak zend.max_allowed_stack_size for gh20836_stack_limit.phpt
2026-02-03 00:55:05 +01:00
Ilija Tovilo 9e96c5ff39 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Tweak zend.max_allowed_stack_size for gh20836_stack_limit.phpt
2026-02-03 00:54:56 +01:00
Ilija Tovilo 1f57d04648 Tweak zend.max_allowed_stack_size for gh20836_stack_limit.phpt
Fixes GH-21086
2026-02-03 00:54:25 +01:00
Ilija Tovilo 6173a9a109 VAR|TMP overhaul (GH-20628)
The aim of this PR is twofold:

- Reduce the number of highly similar TMP|VAR handlers
- Avoid ZVAL_DEREF in most of these cases

This is achieved by guaranteeing that all zend_compile_expr() calls, as well as
all other compile calls with BP_VAR_{R,IS}, will result in a TMP variable. This
implies that the result will not contain an IS_INDIRECT or IS_REFERENCE value,
which was mostly already the case, with two exceptions:

- Calls to return-by-reference functions. Because return-by-reference functions
  are quite rare, this is solved by delegating the DEREF to the RETURN_BY_REF
  handler, which will examine the stack to check whether the caller expects a
  VAR or TMP to understand whether the DEREF is needed. Internal functions will
  also need to adjust by calling the zend_return_unwrap_ref() function.

- By-reference assignments, including both $a = &$b, as well as $a = [&$b]. When
  the result of these expressions is used in a BP_VAR_R context, the reference
  is unwrapped via a ZEND_QM_ASSIGN opcode beforehand. This is exceptionally
  rare.

Closes GH-20628
2026-01-31 19:44:56 +01:00
Alex Dowad 7ad406a4b9 Fix crash in mb_substr with MacJapanese encoding
Thanks to the GitHub user vi3tL0u1s (Viet Hoang Luu) for reporting this issue.

The MacJapanese legacy text encoding has a very unusual property; it is possible for a string
to encode more codepoints than it has bytes. In some corner cases, this resulted in a situation
where the implementation code for mb_substr() would allocate a buffer of size -1. As you can
probably imagine, that doesn't end well.

Fixes GH-20832.
2026-01-18 20:07:12 +09:00
Alexandre Daubois b391c28f90 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix GH-20836: Stack overflow in mb_convert_variables with recursive array references (#20839)
2026-01-14 20:11:31 +01:00