Bug #79019 [NEW]: Copied cURL handles upload empty file

From: Date: Mon, 23 Dec 2019 08:49:22 +0000
Subject: Bug #79019 [NEW]: Copied cURL handles upload empty file
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224487@lists.php.net to get a copy of this message
From: cmb Operating system: * PHP version: 7.4Git-2019-12-23 (Git) Package: cURL related Bug Type: Bug Bug description:Copied cURL handles upload empty file 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 bug report at https://bugs.php.net/bug.php?id=79019&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79019&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79019&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79019&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79019&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79019&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79019&r=support Expected behavior: https://bugs.php.net/fix.php?id=79019&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79019&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79019&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79019&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79019&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79019&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79019&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79019&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79019&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79019&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79019&r=mysqlcfg

« previous php.bugs (#224487) next »