From: Operating system: Linux/Windows PHP version: 5.3.9 Package: cURL related Bug Type: Bug Bug description:Curl file upload send bogus data to lighttpd web server
Description: ------------ Curl file upload fail when destination server was Lighttpd because received data is altered (POST variable FORM_file_name is set to original path of the uploaded file instead of actual file name). Destination server has lighttpd/1.4.29 Test servers had PHP 5.2.4, 5.3.2 (ubuntu 5.14) and 5.3.8 (Windows). Last one was updated to 5.3.9 Following code works on PHP 5.2.x and worked on older versions of PHP, but does not work on any 5.3.x versions. Same code was tested against Apache web server and it worked. Test script: --------------- <?php $url_post['myfile']='@/tmp/test_remote.txt'; $myHeaders=array( "Expect:" ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://xx.xx.xx.xx/cgi-bin/test.sh"); curl_setopt($ch, CURLOPT_PORT, 80); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $myHeaders); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POSTFIELDS, $url_post); $curl_reponse=curl_exec($ch); echo 'Response: '.$curl_reponse; ?> Expected result: ---------------- CONTENT_TYPE=multipart/form-data; boundary=----------------------------0de142dacc53 GATEWAY_INTERFACE=CGI/1.1 HASERL_SHELL=/bin/sh HASERLVER=0.9.27 REMOTE_ADDR=xx.xx.xx.xx POST_myfile=/tmp/m1fafJ HASERL_UPLOAD_DIR=/tmp DOCUMENT_ROOT=/www/ REMOTE_PORT=47209 HTTP_ACCEPT=*/* CONTENT_LENGTH=195 POST_myfile_name=test_remote.txt HASERL_UPLOAD_LIMIT=1000 SCRIPT_FILENAME=/www/cgi-bin/test.sh HTTP_HOST=xx.xx.xx.xx REQUEST_URI=/cgi-bin/test.sh HASERL_myfile_path=/tmp/m1fafJ SERVER_SOFTWARE=lighttpd/1.4.29 HASERL_ACCEPT_ALL=0 FORM_myfile=/tmp/m1fafJ SERVER_PROTOCOL=HTTP/1.1 SESSIONID=6c004f16ab26 REDIRECT_STATUS=200 FORM_myfile_name=test_remote.txt REQUEST_METHOD=POST SERVER_ADDR=0.0.0.0 PWD=/www/cgi-bin/cmh SERVER_PORT=80 SCRIPT_NAME=/cgi-bin/test.sh HTTP_CONTENT_LENGTH=195 SERVER_NAME=xx.xx.xx.xx Actual result: -------------- CONTENT_TYPE=multipart/form-data; boundary=----------------------------bc7136747ad5 GATEWAY_INTERFACE=CGI/1.1 HASERL_SHELL=/bin/sh HASERLVER=0.9.27 REMOTE_ADDR=xx.xx.xx.xx POST_myfile=/tmp/Y9JqDF HASERL_UPLOAD_DIR=/tmp DOCUMENT_ROOT=/www/ REMOTE_PORT=52983 HTTP_ACCEPT=*/* CONTENT_LENGTH=10790 POST_myfile_name=/tmp/test_remote.txt HASERL_UPLOAD_LIMIT=1000 SCRIPT_FILENAME=/www/cgi-bin/test.sh HTTP_HOST=xx.xx.xx.xx REQUEST_URI=/cgi-bin/test.sh HASERL_myfile_path=/tmp/Y9JqDF SERVER_SOFTWARE=lighttpd/1.4.29 HASERL_ACCEPT_ALL=0 FORM_myfile=/tmp/Y9JqDF SERVER_PROTOCOL=HTTP/1.1 SESSIONID=6aa54f16ab0a REDIRECT_STATUS=200 FORM_myfile_name=/tmp/test_remote.txt REQUEST_METHOD=POST SERVER_ADDR=0.0.0.0 PWD=/www/cgi-bin SERVER_PORT=80 SCRIPT_NAME=/cgi-bin/test.sh HTTP_CONTENT_LENGTH=10790 SERVER_NAME=192.168.8.30 -- Edit bug report at https://bugs.php.net/bug.php?id=60788&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60788&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60788&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60788&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=60788&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60788&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=60788&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=60788&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=60788&r=needscript Try newer version: https://bugs.php.net/fix.php?id=60788&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=60788&r=support Expected behavior: https://bugs.php.net/fix.php?id=60788&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=60788&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=60788&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=60788&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60788&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=60788&r=dst IIS Stability: https://bugs.php.net/fix.php?id=60788&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=60788&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=60788&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=60788&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=60788&r=mysqlcfg