1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.4'

* PHP-8.4:
  curl: Fix cloning of POST fields (#19813)
This commit is contained in:
Tim Düsterhus
2025-09-12 20:54:06 +02:00
3 changed files with 39 additions and 1 deletions

4
NEWS
View File

@@ -8,6 +8,10 @@ PHP NEWS
. The __sleep() and __wakeup() magic methods have been deprecated. (Girgias)
. Fixed hard_timeout with --enable-zend-max-execution-timers. (Appla)
- Curl:
. Fix cloning of CURLOPT_POSTFIELDS when using the clone operator instead
of the curl_copy_handle() function to clone a CurlHandle. (timwolla)
- Exif:
. Fix OSS-Fuzz #442954659 (zero-size box in HEIF file causes infinite loop).
(nielsdos)

View File

@@ -423,7 +423,7 @@ static zend_object *curl_clone_obj(zend_object *object) {
clone_ch->cp = cp;
_php_setup_easy_copy_handlers(clone_ch, ch);
postfields = &clone_ch->postfields;
postfields = &ch->postfields;
if (Z_TYPE_P(postfields) != IS_UNDEF) {
if (build_mime_structure_from_hash(clone_ch, postfields) == FAILURE) {
zend_throw_exception(NULL, "Failed to clone CurlHandle", 0);

View File

@@ -0,0 +1,34 @@
--TEST--
clone() allows to post CURLFile multiple times
--EXTENSIONS--
curl
--FILE--
<?php
include 'server.inc';
$host = curl_cli_server_start();
$ch1 = curl_init();
curl_setopt($ch1, CURLOPT_SAFE_UPLOAD, 1);
curl_setopt($ch1, CURLOPT_URL, "{$host}/get.php?test=file");
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
$filename = __DIR__ . '/curl_copy_handle_variation3_clone.txt';
file_put_contents($filename, "Test.");
$file = curl_file_create($filename);
$params = array('file' => $file);
var_dump(curl_setopt($ch1, CURLOPT_POSTFIELDS, $params));
$ch2 = clone($ch1);
var_dump(curl_exec($ch1));
var_dump(curl_exec($ch2));
?>
--EXPECTF--
bool(true)
string(%d) "curl_copy_handle_variation3_clone.txt|application/octet-stream|5"
string(%d) "curl_copy_handle_variation3_clone.txt|application/octet-stream|5"
--CLEAN--
<?php
@unlink(__DIR__ . '/curl_copy_handle_variation3_clone.txt');
?>