Bug #79019 [Asn->Csd]: Copied cURL handles upload empty file

From: Date: Tue, 04 Feb 2020 10:31:40 +0000
Subject: Bug #79019 [Asn->Csd]: Copied cURL handles upload empty file
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225343@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79019&edit=1 ID: 79019 Updated by: cmb@php.net Reported by: cmb@php.net Summary: Copied cURL handles upload empty file -Status: Assigned +Status: Closed Type: Bug Package: cURL related Operating System: * PHP Version: 7.4Git-2019-12-23 (Git) Assigned To: cmb Block user comment: N Private report: N New Comment: Automatic comment on behalf of cmbecker69@gmx.de Revision: http://git.php.net/?p=php-src.git;a=commit;h=2d0dec91a53bddbf9f9e09d9c58188515907d650 Log: Fix #79019: Copied cURL handles upload empty file Previous Comments: ------------------------------------------------------------------------ [2019-12-31 10:14:51] cmb@php.net The following pull request has been associated: Patch Name: Fix #79019: Copied cURL handles upload empty file On GitHub: https://github.com/php/php-src/pull/5045 Patch: https://github.com/php/php-src/pull/5045.patch ------------------------------------------------------------------------ [2019-12-23 08:49:22] cmb@php.net Description: ------------ If a cURL handle which has a CURLFile attached as post field is copied via curl_copy_handle(), the file upload can only succeed the first time it is executed; subsequent executions of the handle copies will upload an empty file. The problem is that the current implementation of request #77711 opens the stream and attaches it to the cURL handle; on the first upload the stream is completely read, but not rewound afterwards (what is not generally possible, anyway), so subsequent uploads only see an empty stream. Test script: --------------- Apply the following patch: ext/curl/tests/responder/get.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/curl/tests/responder/get.inc b/ext/curl/tests/responder/get.inc index f9269745f6..64ab267d50 100644 --- a/ext/curl/tests/responder/get.inc +++ b/ext/curl/tests/responder/get.inc @@ -28,7 +28,7 @@ break; case 'file': if (isset($_FILES['file'])) { - echo $_FILES['file']['name'] . '|' . $_FILES['file']['type']; + echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'] . '|' . $_FILES['file']['size']; } break; case 'method': And run ext/curl/tests/curl_copy_handle_variation3.phpt Expected result: ---------------- bool(true) string(37) "АБВ.txt|application/octet-stream|5" string(37) "АБВ.txt|application/octet-stream|5" ===DONE=== Actual result: -------------- bool(true) string(37) "АБВ.txt|application/octet-stream|5" string(37) "АБВ.txt|application/octet-stream|0" ===DONE=== ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79019&edit=1

« previous php.bugs (#225343) next »