15940 Commits
Author SHA1 Message Date
ndossche 8867746907 Merge branch 'PHP-8.6'
* PHP-8.6:
  Fix use-after-free in Randomizer::shuffleArray() when the engine throws
2026-10-28 08:25:23 +01:00
ndossche 30bcf4bd89 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Fix use-after-free in Randomizer::shuffleArray() when the engine throws
2026-10-28 08:25:17 +01:00
ndossche dbd6ed433d Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix use-after-free in Randomizer::shuffleArray() when the engine throws
2026-10-28 08:24:57 +01:00
Martin Mirchev 3a8bcb6d18 Fix use-after-free in Randomizer::shuffleArray() when the engine throws
php_array_data_shuffle() first compacts the holes of a packed array and
only then updates nNumUsed. When the engine threw in between, the stale
tail slots were still counted, so the moved values were released twice
when the copied array was destroyed. Update nNumUsed right after the
compaction.

Closes GH-24553.
2026-10-28 08:24:25 +01:00
David Carlier 6f301fa58b Merge branch 'PHP-8.6'
* PHP-8.6:
  Fix GH-24616: Socket transports accept ports above 65535
2026-10-27 15:37:35 +00:00
David Carlier fed2b4e17f Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Fix GH-24616: Socket transports accept ports above 65535
2026-10-27 15:37:34 +00:00
David Carlier 247199192c Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-24616: Socket transports accept ports above 65535
2026-10-27 15:37:28 +00:00
Arnaud Le Blanc 947c556ba2 Assert that destroyed hash tables are not in GC buffer (#24739) 2026-10-27 16:24:23 +01:00
Martin Mirchev bad5aaca7a Fix GH-24616: Socket transports accept ports above 65535
parse_ip_address_ex() and php_network_parse_network_address_with_port()
read the port with atoi() and did not check its range, so a port above
65535 or below 0 silently wrapped to another port. Reject such ports.

bug69521.phpt relied on this wrapping (port 74321), use an ephemeral
port instead.

Close GH-24621
2026-10-27 15:19:19 +00:00
Weilin Du c47875f47b Merge branch 'PHP-8.6'
* PHP-8.6:
  Fix GH-24552: Use ASCII case folding in string comparisons (#24558)
2026-10-27 21:23:26 +08:00
Weilin Du 04a5da0ab6 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Fix GH-24552: Use ASCII case folding in string comparisons (#24558)
2026-10-27 21:23:12 +08:00
Weilin Du 6a020d606e Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-24552: Use ASCII case folding in string comparisons (#24558)
2026-10-27 21:22:44 +08:00
lazergandJon Surrell 872c6e19c4 Fix GH-24552: Use ASCII case folding in string comparisons (#24558)
PHP 8.2 made case-insensitive comparisons ASCII-only, but ksort() and
krsort() with SORT_STRING | SORT_FLAG_CASE and substr_compare() with
case_insensitive=true still used the locale-sensitive _l variants.
These call tolower() and depend on LC_CTYPE.

Use zend_binary_strcasecmp() and zend_binary_strncasecmp(), consistent
with sort() and strncasecmp(), so these comparisons also use ASCII case
folding regardless of the current locale.

Fixes #24552

Co-authored-by: Jon Surrell <sirreal@users.noreply.github.com>

Closes #24558
2026-10-27 21:21:44 +08:00
Weilin Du 815aab56e8 Merge branch 'PHP-8.6'
* PHP-8.6:
  Fix GH-24605: Guard var_export() against native stack overflow (#24671)
2026-10-27 13:38:44 +08:00
Weilin Du 4f8d7bb668 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Fix GH-24605: Guard var_export() against native stack overflow (#24671)
2026-10-27 13:38:29 +08:00
Weilin Du 71e8293fa2 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-24605: Guard var_export() against native stack overflow (#24671)
2026-10-27 13:37:41 +08:00
Labish Bardiya afe5635c3f Fix GH-24605: Guard var_export() against native stack overflow (#24671)
Deeply nested arrays and objects can exhaust the native stack because
php_var_export_ex() recursively exports their contents without checking
Zend's stack limit.

Check the native stack limit and throw a catchable Error when it is reached.
Propagate failures from recursive object property exports while releasing
temporary values, property tables, and recursion guards on the failure path.

Add regression coverage for deeply nested arrays and objects with a reduced
stack limit. This fixes only the var_export() part of GH-24605; print_r() and
unserialize() remain outside this change's scope.

Closes #24671
2026-10-27 13:36:59 +08:00
Sjoerd Langkemper cadc689e6b ext/standard: remove unnecessary var_hash check (#24744)
var_hash is never null. It is dereferenced elsewhere in the function, so
this function would already crash if it were null. Remove null check and
add assertion.
2026-10-26 21:19:58 +01:00
Artem Ukrainskiy 219289d8e7 ext/standard: Stop at the first non-name byte in html_entity_decode() (#24142)
Entity names are letters and digits. Scan them and stop at the first other
byte instead of searching for a ';' up to 32 bytes ahead and hashing whatever
is in between. Also skip memchr() when the next byte is already '&'.

Output is unchanged. html_entity_decode() on 4 KB inputs:

  only '&'                      3.5x faster
  only entities                 1.1x faster
  jQuery source                 1.1-1.4x faster
  jQuery minified               1.4-1.7x faster
  HTML pages, Markdown          same
  "&param=value" URLs in text   up to 1.07x slower
2026-10-26 08:25:18 -04:00
Jorg Sowa 2a98b8d01e Merge branch 'PHP-8.6' 2026-10-24 21:20:24 +02:00
Jorg Sowa a0538c006f Merge branch 'PHP-8.5' into PHP-8.6 2026-10-24 21:20:23 +02:00
Jorg Sowa 24f8027822 Merge branch 'PHP-8.4' into PHP-8.5 2026-10-24 21:20:18 +02:00
Jorg SowaandDavid Carlier 0ddabc30e8 ext/standard: Skip proc_open descriptor 0 tests without /proc/self/fd symlinks
On Solaris/illumos /proc/self/fd entries are not symlinks, so readlink()
fails with EINVAL.

Co-authored-by: David Carlier <devnexen@gmail.com>

Closes GH-24571.
2026-10-24 21:20:15 +02:00
ndossche 45869fa68a Merge branch 'PHP-8.6'
* PHP-8.6:
  Fix GH-24509: HTTP wrapper leaks Location buffer on empty Location header
2026-10-24 00:42:28 +02:00
ndossche 4c2924299c Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Fix GH-24509: HTTP wrapper leaks Location buffer on empty Location header
2026-10-24 00:42:23 +02:00
ndossche 48b3f94fe2 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-24509: HTTP wrapper leaks Location buffer on empty Location header
2026-10-24 00:42:07 +02:00
berce ad7ad7c425 Fix GH-24509: HTTP wrapper leaks Location buffer on empty Location header
location_len == 0 was used to mean that no buffer was allocated yet, but an empty Location header allocates a 1-byte buffer and leaves location_len at 0. A second Location header then allocated a new buffer and leaked the first. Check the pointer instead.

Closes GH-24512.
2026-10-24 00:41:40 +02:00
Lazizbek Ergashev 551967dd91 Fix GH-24491: Static method stream error handler replaces pending exception (#24520)
Since 2f7b01b86c, `zend_is_callable()` fills in an error string even when it fails because an exception is already pending, so `php_stream_call_error_handler()` threw a TypeError over the StreamException (or whatever the user error handler threw) for any `Class::method` handler. It now only throws when nothing is pending, the same way curl already does.

The same commit made `zend_parse_arg()` leak that error string when it bails out on a pending exception, so it's freed there now too.

Fixes GH-24491
2026-10-23 20:57:32 +01:00
Gina Peter Banyard 216c56ebf0 std: use {BEGIN|END}_EXTERN_C() compatibility macro 2026-10-23 20:50:50 +01:00
Weilin Du 237553252c Merge branch 'PHP-8.6'
* PHP-8.6:
  Fix GH-24308: Preserve syslog handles not opened by PHP (#24310)
2026-10-24 00:41:50 +08:00
Weilin Du 13f0820058 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Fix GH-24308: Preserve syslog handles not opened by PHP (#24310)
2026-10-24 00:40:46 +08:00
Weilin Du 48786b4dc1 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-24308: Preserve syslog handles not opened by PHP (#24310)
2026-10-24 00:39:50 +08:00
lazerg b0c8e27b27 Fix GH-24308: Preserve syslog handles not opened by PHP (#24310)
Only close syslog at request shutdown when PHP has opened it, so embedded
hosts retain their syslog connection across requests that do not use it.

When syslog() is called before openlog(), explicitly open the connection
using syslog.ident and syslog.facility, as error_log=syslog already does.
This tracks the connection for request cleanup and changes the implicit
syslog() identity and facility to the configured PHP values.

Add a regression test checking that a connection opened by syslog() is
closed before the next request.

Closes #24310
2026-10-24 00:38:34 +08:00
Pratik Bhujel 981c083a65 ext/standard: Add regression test for GH-21824 (#21828) 2026-10-23 05:29:59 +01:00
David Carlier da7da45a44 Merge branch 'PHP-8.6'
* PHP-8.6:
  Fix GH-24373: serialize() context reused by destructors during teardown
2026-10-22 20:27:49 +01:00
David Carlier 2c3ae32fc3 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Fix GH-24373: serialize() context reused by destructors during teardown
2026-10-22 20:27:03 +01:00
David Carlier 267ec8e12b Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-24373: serialize() context reused by destructors during teardown
2026-10-22 20:26:07 +01:00
David Carlier 08f4b64e0a Fix GH-24373: serialize() context reused by destructors during teardown
The context was destroyed while still registered. Unregister it first.

Close GH-24452
2026-10-22 20:24:43 +01:00
Weilin Du 12ef787293 Merge branch 'PHP-8.6'
* PHP-8.6:
  ci: Fix OOM failures in header_over_4gib.phpt
2026-10-23 02:03:42 +08:00
Weilin Du 1ec36cfdd9 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  ci: Fix OOM failures in header_over_4gib.phpt
2026-10-23 02:03:37 +08:00
Weilin Du 550255df0e Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ci: Fix OOM failures in header_over_4gib.phpt
2026-10-23 02:02:50 +08:00
Weilin Du b232da5d0a ci: Fix OOM failures in header_over_4gib.phpt
The test keeps a header larger than 4 GiB alive while sapi_header_op()
duplicates it, so its peak memory usage exceeds 8 GiB. The 6 GiB FreeBSD
CI VM can kill either the test process (Termsig=9) or a test worker.

Skip the test on FreeBSD, following ext/bz2/tests/gh20807.phpt. Run it in
isolation with --CONFLICTS-- all so other tests do not add to its memory
pressure on the remaining platforms.
2026-10-23 02:02:19 +08:00
Weilin Du e7593aed87 Merge branch 'PHP-8.6'
* PHP-8.6:
  Fix infinite loop in sapi_header_op() for headers of 4 GiB or more (#24540)
2026-10-23 00:58:24 +08:00
Weilin Du d6690b5157 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Fix infinite loop in sapi_header_op() for headers of 4 GiB or more (#24540)
2026-10-23 00:57:57 +08:00
Weilin Du a310887187 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix infinite loop in sapi_header_op() for headers of 4 GiB or more (#24540)
2026-10-23 00:57:33 +08:00
Martin Mirchev 7ff3af0f42 Fix infinite loop in sapi_header_op() for headers of 4 GiB or more (#24540)
The new line/NUL check uses a uint32_t index to scan a header whose length
is size_t. For header lines of 4 GiB or more, the index wraps around and
the request never finishes. This also affects session_start() when a
cookie path, domain or session ID produces a header of that size.

Use size_t for the index so it can reach the full header length. Add a
resource-heavy regression test using header() directly, with a newline
after 4 GiB to verify that header validation completes and emits the
usual warning. The test requires a 64-bit platform and runs only when
RUN_RESOURCE_HEAVY_TESTS is enabled and SKIP_SLOW_TESTS is unset.

Closes #24540
2026-10-23 00:48:30 +08:00
ndossche a2e4d85bf3 Merge branch 'PHP-8.6'
* PHP-8.6:
  Fix GH-24508: HTTP wrapper leaks dechunk filter when header parsing fails
2026-10-22 16:37:34 +02:00
ndossche 1c5b0e5b12 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Fix GH-24508: HTTP wrapper leaks dechunk filter when header parsing fails
2026-10-22 16:37:15 +02:00
ndossche 17b4c5f4f1 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-24508: HTTP wrapper leaks dechunk filter when header parsing fails
2026-10-22 16:37:00 +02:00
berce 4fd56dc469 Fix GH-24508: HTTP wrapper leaks dechunk filter when header parsing fails
The dechunk filter created for Transfer-Encoding: chunked is only appended to the stream's read filters when a stream comes back. When a later header line fails to parse, the stream is closed and the filter was never freed. Free it when there is no stream to own it.

Closes GH-24513.
2026-10-22 16:36:29 +02:00