php.net |  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: cmb@php.net 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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: cmb@php.net
New email:
PHP Version: OS:

 

 [2019-12-23 08:49 UTC] 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===


Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-12-23 08:49 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2019-12-31 10:14 UTC] 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
 [2020-02-04 10:31 UTC] cmb@php.net
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
 [2020-02-04 10:31 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 27 16:01:27 2024 UTC