[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:
Marc Alexander 2014-06-24 19:07:49 +02:00
parent 5ee1e07e17
commit 309dbb4ef9

View file

@ -803,13 +803,23 @@ class fileupload
$get_info = false;
$data = '';
$length = false;
$timer_stop = time() + $this->upload_timeout;
while (!@feof($fsock))
while (!($length && $filesize >= $length) && !@feof($fsock))
{
if ($get_info)
{
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);
if ($remote_max_filesize && $filesize > $remote_max_filesize)