|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79019 Copied cURL handles upload empty file
Submitted: 2019-12-23 08:49 UTC Modified: 2019-12-23 08:49 UTC
From: Assigned: cmb (profile)
Status: Closed Package: cURL related
PHP Version: 7.4Git-2019-12-23 (Git) OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
New email:
PHP Version: OS:


 [2019-12-23 08:49 UTC]
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/ | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ext/curl/tests/responder/ b/ext/curl/tests/responder/
index f9269745f6..64ab267d50 100644
--- a/ext/curl/tests/responder/
+++ b/ext/curl/tests/responder/
@@ -28,7 +28,7 @@
     case 'file':
       if (isset($_FILES['file'])) {
-          echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
+          echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'] . '|' . $_FILES['file']['size'];
     case 'method':

And run ext/curl/tests/curl_copy_handle_variation3.phpt

Expected result:
string(37) "АБВ.txt|application/octet-stream|5"
string(37) "АБВ.txt|application/octet-stream|5"

Actual result:
string(37) "АБВ.txt|application/octet-stream|5"
string(37) "АБВ.txt|application/octet-stream|0"


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-12-23 08:49 UTC]
-Assigned To: +Assigned To: cmb
 [2019-12-31 10:14 UTC]
The following pull request has been associated:

Patch Name: Fix #79019: Copied cURL handles upload empty file
On GitHub:
 [2020-02-04 10:31 UTC]
Automatic comment on behalf of
Log: Fix #79019: Copied cURL handles upload empty file
 [2020-02-04 10:31 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 15 11:01:29 2024 UTC