mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
[ticket/12755] Terminate upload loop if upload reaches filesize
Terminate the upload loop if the expected filesize has been reached instead of trying to read more bytes until the timeout has been reached. PHPBB3-12755
This commit is contained in:
parent
5ee1e07e17
commit
309dbb4ef9
1 changed files with 12 additions and 2 deletions
|
@ -803,13 +803,23 @@ class fileupload
|
||||||
|
|
||||||
$get_info = false;
|
$get_info = false;
|
||||||
$data = '';
|
$data = '';
|
||||||
|
$length = false;
|
||||||
$timer_stop = time() + $this->upload_timeout;
|
$timer_stop = time() + $this->upload_timeout;
|
||||||
|
|
||||||
while (!@feof($fsock))
|
while (!($length && $filesize >= $length) && !@feof($fsock))
|
||||||
{
|
{
|
||||||
if ($get_info)
|
if ($get_info)
|
||||||
{
|
{
|
||||||
$block = @fread($fsock, 1024);
|
if ($length)
|
||||||
|
{
|
||||||
|
// Don't attempt to read past end of file if server indicated length
|
||||||
|
$block = @fread($fsock, min($length - $filesize, 1024));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$block = @fread($fsock, 1024);
|
||||||
|
}
|
||||||
|
|
||||||
$filesize += strlen($block);
|
$filesize += strlen($block);
|
||||||
|
|
||||||
if ($remote_max_filesize && $filesize > $remote_max_filesize)
|
if ($remote_max_filesize && $filesize > $remote_max_filesize)
|
||||||
|
|
Loading…
Add table
Reference in a new issue