[PHP-BUG] Bug #74318 [NEW]: Partially uploaded files are not deleted
[email protected] ("vobruba dot martin at gmail dot com")
| Newsgroups | php.bugs |
|---|---|
| Message-ID | <[email protected]> |
From: vobruba dot martin at gmail dot com
Operating system:
PHP version: 7.1.3
Package: Apache2 related
Bug Type: Bug
Bug description:Partially uploaded files are not deleted
Description:
------------
If you make an incomplete upload request (Content-Length header value is
larger than POSTed body) a temporary upload_tmp_dir/php* file won't be
deleted after the request is processed by server which is bad because
upload_tmp_dir is growing in size.
I think that this is related to this patch
https://github.com/php/php-src/pull/2323 because I cannot replicate this
problem in 7.1.2.
Test script:
---------------
<?php
$rn = "\r\n";
$boundary = '------------------BOUNDARY';
$fileSize = 5 * 1024 * 1024; // upload size must be larger than input
buffer size
$offset = 1000; // should cause timeout if distinctly larger than 0
$connectHost = 'CHANGE.THIS.HOST';
$connectPort = 443;
$connectProto = 'ssl';
$requestUri = '/upload.php';
$content = '--'.$boundary.$rn;
$content .= 'Content-Disposition: form-data; name="file";
filename="test.txt"'.$rn;
$content .= 'Content-Type: application/octet-stream'.$rn.$rn;
$content .= str_repeat('a', $fileSize).$rn;
$content .= '--'.$boundary.'--';
$headers = 'POST '.$requestUri.' HTTP/1.1'.$rn;
$headers .= 'Host: '.$connectHost.$rn;
$headers .= 'Connection: close'.$rn;
$headers .= 'Content-Length: '.(strlen($content) + $offset).$rn;
$headers .= 'Content-Type: multipart/form-data;
boundary='.$boundary.$rn.$rn;
$socket = fsockopen($connectProto.'://'.$connectHost, $connectPort);
fwrite($socket, $headers.$rn.$content);
while(!feof($socket)) {
echo fread($socket, 1024);
}
fclose($socket);
Expected result:
----------------
Associated upload_tmp_dir/php* file is deleted after the request is
processed.
Actual result:
--------------
Associated upload_tmp_dir/php* file is not deleted.
--
Edit bug report at https://bugs.php.net/bug.php?id=74318&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74318&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74318&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74318&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74318&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74318&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74318&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74318&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74318&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74318&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74318&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74318&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74318&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74318&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74318&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74318&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74318&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74318&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74318&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74318&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74318&r=mysqlcfg