2711 Commits
Author SHA1 Message Date
Arnaud Le Blanc a2486445bd Destructor of regular arrays must be ZVAL_PTR_DTOR or NULL (#24727) 2026-10-27 16:28:34 +01:00
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 04c2058c6d Merge branch 'PHP-8.6' 2026-10-12 14:36:02 +01: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
Kamil Tekiela 896653dbd2 ext/mbstring: Validate and flag UTF-8 in mb_strlen() to improve performance (#24024) 2026-09-30 18:19:43 +01:00
Daniel Scherzer 8906dc2518 ext/mbstring: assert that mb_wchar_to_uuencode() pointer write is in bounds (#23955)
Add a hardening assertion that when `mb_wchar_to_uuencode()` needs to update
the length of the previous line, the location being written to is still part of
the same overall output string (i.e. at or after the start of the buffer's
`str`'s value pointer, and before the end of the char array).
2026-09-28 16:56:03 -07: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 DuandDavid CARLIER ae62043aa3 ext/mbstring: Optimize mb_str_pad() using doubling copies (#23667)
Follow-up #23661. Use the same optimization on mb_str_pad.

Co-authored-by: David CARLIER <devnexen@gmail.com>
2026-09-13 00:04:17 +08: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
Dmytro Kulyk 67135cb97b gen_stub: Conditionally include zend_attributes.h to arginfo based on usage (#21570)
Headers required by the generated code (zend_attributes.h, zend_constants.h, zend_enum.h) are collected during generation and emitted as includes at the top of the arginfo file, with the same preprocessor conditions and PHP version guards as the code that needs them.

Removes the manual zend_attributes.h and zend_enum.h includes from sources that only needed them for the arginfo file they include.
2026-09-06 21:25:20 +02: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
Daniel Scherzer 7db6f5b021 Arginfo: add and use known string for "8.6" (#23222) 2026-08-11 15:36:31 -07: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
Ilia Alshanetsky 8db6246800 Merge branch 'PHP-8.5'
* PHP-8.5:
  mbstring: Fix memory leak in mail header parsing
2026-06-11 07:42:02 -04:00
Ilia Alshanetsky d641a9f3bc Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  mbstring: Fix memory leak in mail header parsing
2026-06-11 07:40:09 -04:00
Ilia Alshanetsky 61a1b9afd6 mbstring: Fix memory leak in mail header parsing
A header field name with no value (input ending at the colon) leaves
fld_name allocated but unreleased, since the cleanup blocks only fire
when both fld_name and fld_val are set. Release the dangling fld_name in
both the loop-body and end-of-input branches.

Closes GH-22254
2026-06-11 07:38:00 -04: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