1634 Commits
Author SHA1 Message Date
ndossche beb8d76332 Merge branch 'PHP-8.6'
* PHP-8.6:
  curl: Fix UAF on clone due to callback data pointer mismatch
2026-10-27 20:44:39 +01:00
ndossche f8176205c7 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  curl: Fix UAF on clone due to callback data pointer mismatch
2026-10-27 20:44:34 +01:00
ndossche 625892b770 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  curl: Fix UAF on clone due to callback data pointer mismatch
2026-10-27 20:44:17 +01:00
ndossche 154b090df2 curl: Fix UAF on clone due to callback data pointer mismatch
When curl opaque objects are cloned, the curl handle was only updated if
the callback function wasn't null. However, the C handler in PHP remains
attached even if the callback was set to NULL (*). So we must
unconditionally update the callback data pointer to the new curl handle.

(*) We can't set the C handler to NULL unconditionally on stable branches
because that invokes a behaviour change (e.g. built in progress bar).

Closes GH-24760.
2026-10-27 20:43:46 +01:00
ndossche 05d2e81ec7 Merge branch 'PHP-8.6'
* PHP-8.6:
  Fix use-after-free of CURLOPT_STDERR stream on cloned curl handle
2026-10-26 22:09:26 +01:00
ndossche dc9660471d Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Fix use-after-free of CURLOPT_STDERR stream on cloned curl handle
2026-10-26 22:09:21 +01:00
ndossche 2546fe9e82 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix use-after-free of CURLOPT_STDERR stream on cloned curl handle
2026-10-26 22:09:05 +01:00
lacatoire 59f8e1d265 Fix use-after-free of CURLOPT_STDERR stream on cloned curl handle
_php_setup_easy_copy_handlers() copies the write, read and write_header
streams but not std_err. The clone never checks that stream is still
open, so libcurl keeps writing to a FILE* freed when the stream is
closed.

Copy std_err like the other handlers.

Closes GH-24427.
2026-10-26 22:08:42 +01:00
Lazizbek Ergashev 3d3d3665a7 Fix GH-24533: Accept z.lib from zlib 1.3.2 CMake builds on Windows (#24539)
* Fix GH-24533: Accept z.lib from zlib 1.3.2 CMake builds on Windows

* Prefer static zs.lib and add NEWS entry

* Accept zlib 1.3.2 lib names in the other zlib lookups
2026-10-22 22:14:05 +05:30
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
Gina Peter BanyardandArnaud Le Blanc 2f7b01b86c Zend: always populate error pointer on failure of zend_is_callable() (#24435)
* Zend: always populate error pointer on failure

Most of the code base expects an error to be set if a char* is provided, as this used to be always the case. It no longer was the case since the partially supported callables were deprecates as the deprecation could be promoted to an exception in which case we skipped allocating a char*.

The simple fix, allocate a char* even in case of an exception so callers don't need to check if it still NULL. This fixes some error messages at the same time.

* tree: simplify error handling for failed zend_is_callable() calls

* docs: clarify docs for zend_is_callable()

---------

Co-authored-by: Arnaud Le Blanc <365207+arnaud-lb@users.noreply.github.com>
2026-10-20 17:59:02 +01:00
Sjoerd Langkemper cd583348b1 ext/curl: speed up tests (#23228)
By waiting shorter for the server to be ready.

The first check for output on stderr takes approximately 10ms, so we
wait 20ms to make sure its ready. The second check for the open port
typically succeeds immediately, so move the sleep to after we have
tried.

Change the numbers in curl_setopt_ssl.phpt for consistency.
2026-10-18 12:51:50 +02:00
Sjoerd Langkemper 2544d0b7d9 ext/curl: post multiple similarly-named files (#22740)
Make it possible to post multiple files with the same name using cURL.
It was already possible to post files, and it was possible to post
multiple strings with the same name. This moves things around to combine
these two features.

Closes GH-15859
2026-10-14 19:28:54 +02:00
Arshid 595abc18ee ext/curl: Remove unused return_value parameter from _php_curl_multi_setopt (#24253) 2026-10-11 13:36:35 +02:00
Arshid 90a65ec8cb ext/curl: Use try conversion functions in curl (#24067) 2026-10-06 22:30:40 +02:00
Gina Peter Banyard 344a925015 Merge branch 'PHP-8.6'
* PHP-8.6:
  ext/curl/config.m4: include string.h for test using strncmp()
  ext/soap/tests/bugs/bug62900.phpt: make use of TEST_PHP_ vars
  sapi/cli/tests/php_cli_server_ipv6_error_message.phpt: use TEST_PHP_ vars
2026-09-30 15:57:18 +01:00
Gina Peter Banyard acd290ef1f Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  ext/curl/config.m4: include string.h for test using strncmp()
  ext/soap/tests/bugs/bug62900.phpt: make use of TEST_PHP_ vars
  sapi/cli/tests/php_cli_server_ipv6_error_message.phpt: use TEST_PHP_ vars
2026-09-30 15:56:59 +01:00
Michael Orlitzky 54f94852bb ext/curl/config.m4: include string.h for test using strncmp()
Commit 2ecafd41ba updates one of the curl ./configure tests to use
strncmp(), but that function may not be defined unless string.h is
included. We add it here.

Closes GH-23208
2026-09-30 15:56:35 +01:00
Weilin Du 18e83bdb1a Merge branch 'PHP-8.6'
* codex/pr23944-php86:
  CI: Fix flacky ext\curl\tests\curl_setopt_ssl.phpt (#23944)
2026-09-29 00:28:22 +08:00
Weilin Du 1da20af57b Merge branch 'PHP-8.5' into PHP-8.6
* codex/pr23944-php85:
  CI: Fix flacky ext\curl\tests\curl_setopt_ssl.phpt (#23944)
2026-09-29 00:28:01 +08:00
Weilin Du 4cddb9da26 Merge branch 'PHP-8.4' into PHP-8.5
* origin/PHP-8.4:
  CI: Fix flacky ext\curl\tests\curl_setopt_ssl.phpt (#23944)
2026-09-29 00:27:18 +08:00
Weilin Du 1f1790940a CI: Fix flacky ext\curl\tests\curl_setopt_ssl.phpt (#23944)
Sometimes, 1 sec in not enough for the service to start.
This test is flacky because of this in my server, also in gh CI:
https://github.com/php/php-src/actions/runs/36204765497/job/108298870351
2026-09-29 00:24:36 +08:00
Weilin Du b30219a44a CI: Fix curl_callback_lifetime_destructor.phpt (#23884) 2026-09-24 13:14:12 +01:00
David Carlier b27f4a251d Merge branch 'PHP-8.6'
* PHP-8.6:
  sapi/cli: Fix crash in the CLI server when a client is reset before being accepted
2026-09-24 11:02:57 +01:00
David Carlier 7e0b2e044c Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  sapi/cli: Fix crash in the CLI server when a client is reset before being accepted
  ext/curl: Preserve callback lifetime without rejecting callback changes (#23863)

# Conflicts:
#	ext/curl/interface.c
2026-09-24 11:02:56 +01:00
David Carlier b0ea8b2537 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  sapi/cli: Fix crash in the CLI server when a client is reset before being accepted
  ext/curl: Preserve callback lifetime without rejecting callback changes (#23863)
2026-09-24 11:02:50 +01:00
Weilin Du e0fc65dabc Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  ext/curl: Preserve callback lifetime without rejecting callback changes (#23863)
2026-09-24 11:57:12 +08:00
Weilin Du f7b9bcc5b5 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/curl: Preserve callback lifetime without rejecting callback changes (#23863)
2026-09-24 11:56:31 +08:00
Weilin DuandNicolas Grekas 9e7117f20f ext/curl: Preserve callback lifetime without rejecting callback changes (#23863)
Keep callback receivers and closures alive until their calls return, allowing
callbacks to replace or clear themselves without freeing an active receiver.
This preserves existing usage such as Symfony HttpClient's write callback.

Use the helper for all callback entry points and retain the in_callback guard
while releasing the temporary references, as destructors may re-enter curl.
Add regression tests for replacement, clearing, trampolines, exceptions and
destructor re-entry.

Co-authored-by: Nicolas Grekas <nicolas.grekas@gmail.com>
2026-09-24 10:19:32 +08:00
Weilin Du 6d22c49dde Merge branch 'PHP-8.4' into PHP-8.5
Propagate the backport of PR #23814 from PHP-8.4 to PHP-8.5.

* PHP-8.4:
  Backport: reject cURL callback changes from callbacks (#23814)
2026-09-22 01:53:19 +08:00
jvoisin d82f1ff50f Backport: reject cURL callback changes from callbacks (#23814)
Backport PR #23814 from master to PHP-8.4.
Original commit: 840625f266

php_curl_set_callable_handler() frees the previously registered callback with
zend_fcc_dtor() before installing the new one. The write/read/header/progress/
etc. callbacks run with ch->in_callback set, so calling curl_setopt() with one
of the callable options (CURLOPT_WRITEFUNCTION, CURLOPT_READFUNCTION, ...) from
inside such a callback destroys the fcc that is still executing. For a
non-closure callback such as [$obj, 'method'] whose object is only referenced
by the fcc, this releases $this while its method is still on the stack,
resulting in a use-after-free (closures are kept alive by the call frame,
method receivers are not).

Reject setting a callable option while inside a callback, matching the existing
in_callback guards on curl_close() and curl_reset().

Closes #23814
2026-09-22 01:53:18 +08:00
Julien Voisin 840625f266 ext/curl: fix use-after-free when setting a callback option from its own callback (#23814)
php_curl_set_callable_handler() frees the previously registered callback with
zend_fcc_dtor() before installing the new one. The write/read/header/progress/
etc. callbacks run with ch->in_callback set, so calling curl_setopt() with one
of the callable options (CURLOPT_WRITEFUNCTION, CURLOPT_READFUNCTION, ...) from
inside such a callback destroys the fcc that is still executing. For a
non-closure callback such as [$obj, 'method'] whose object is only referenced
by the fcc, this releases $this while its method is still on the stack,
resulting in a use-after-free (closures are kept alive by the call frame,
method receivers are not).

Reject setting a callable option while inside a callback, matching the existing
in_callback guards on curl_close() and curl_reset().
2026-09-21 16:36:35 +01:00
Gina Peter Banyard 2847f6066a ext/curl: remove XFAIL section for tests that are fixed (#22460)
Closes GH-16074
2026-09-21 16:35:31 +01:00
Daniel Scherzer ed8ff1ec53 CLI server: remove "Host" header reflection from response
The server previously responded with a copy of the requested "Host" header in
the response, without any validation. That header, as defined in RFC 9110, is
intended for use in *requests*; remove it from the responses.
2026-09-20 15:35:15 -07:00
Jordi Kroon 6e14f88bb4 curl: replace external URLs with local test server in tests (#21805) 2026-09-16 13:46:30 +01: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
Sjoerd Langkemper c282f04efd ext/curl: add more tests (#23333)
- CURLOPT_WRITEHEADER

- CURLOPT_MAXFILESIZE_LARGE

- CURLOPT_POSTREDIR

- CURLOPT_SSH_HOSTKEYFUNCTION

- CURLOPT_FNMATCH_FUNCTION

- CURLINFO_HEADER_OUT

- read_cb by sending a CURLFile twice

- CURLINFO_CERTINFO

- CURLE_ error constants
2026-08-29 15:34:51 +01:00
Sjoerd Langkemper 5e5839904f ext/curl: set curl post size using CURLOPT_POSTFIELDSIZE_LARGE (#22842)
This is a 64-bit number on all platforms. This improves support of
posting files larger than 2GB.

- https://curl.se/libcurl/c/CURLOPT_POSTFIELDSIZE.html
- https://curl.se/libcurl/c/CURLOPT_POSTFIELDSIZE_LARGE.html
2026-08-16 19:51:14 +01:00
NickSdot 337af2feab ext/curl: Test exception types in tests added in #22745
Follow up to #22745.
2026-08-14 01:11:36 +08:00
NickSdot a8d0fb4229 ext/curl: Test exception type in curl_read_function_error_on_int.phpt‎
Follow up to #22757
2026-08-14 01:10:32 +08:00
NickSdot a1fdc0b934 ext/curl: applied fixers to improve test robustness (#23038) 2026-08-12 19:17:12 +08:00
Sjoerd Langkemper 28febe2a91 ext/curl: abort curl transfer if callback throws exception (#22745)
Closes GH-16513

Closes GH-16790
2026-08-07 19:16:08 +01:00
Sjoerd Langkemper 6a4ab2ed30 ext/curl: show curl option name in error message (#22908) 2026-08-06 13:10:54 +02:00
Sjoerd Langkemper ac37a9760b ext/curl: error when curl read func returns unexpected long
Raise a value error when the callback registered with
CURLOPT_READFUNCTION returns an unexpected long.

The function registered with CURLOPT_READFUNCTION should return a
string. PHP then writes that string to a buffer and returns the
length, so that curl can read that many bytes from the buffer.

The function can also return CURL_READFUNC_ABORT and
CURL_READFUNC_PAUSE, so it also supports returning longs. However, when
it returns a long other than these two constants, it is interpreted as a
length. PHP does not update the buffer, but does instruct curl it can
read that many bytes from the buffer. It reads whatever uninitialized
data that is in the buffer and sends it over the line to the server.

This seems bad, so validate the return value of the read function and
raise an error.

Returning 0 is a bit of an edge case. It is not documented but does
results in correct behavior (i.e. end-of-file). So we accept that, but
don't advertise it as valid in the error message.

Related to https://github.com/php/php-src/issues/10270

Close GH-22757
2026-08-05 21:59:28 +01:00
Weilin Du 99d2e3c166 Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/curl: fix mem leak when duphandle fails in curl_clone_obj (#22899)
2026-07-27 22:37:30 +08:00