mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 23:45:20 +02:00
[ticket/12755] Add timeout to remote upload to prevent infinite loop
PHPBB3-12755
This commit is contained in:
parent
51b2cc14f8
commit
0499655ba4
@ -466,6 +466,9 @@ class fileupload
|
||||
var $max_height = 0;
|
||||
var $error_prefix = '';
|
||||
|
||||
/** @var int Timeout for remote upload */
|
||||
var $upload_timeout = 5;
|
||||
|
||||
/**
|
||||
* Init file upload class.
|
||||
*
|
||||
@ -785,6 +788,9 @@ class fileupload
|
||||
return $file;
|
||||
}
|
||||
|
||||
// Set a proper timeout for the socket
|
||||
socket_set_timeout($fsock, $this->upload_timeout);
|
||||
|
||||
// Make sure $path not beginning with /
|
||||
if (strpos($path, '/') === 0)
|
||||
{
|
||||
@ -797,6 +803,8 @@ class fileupload
|
||||
|
||||
$get_info = false;
|
||||
$data = '';
|
||||
$upload_start = time();
|
||||
|
||||
while (!@feof($fsock))
|
||||
{
|
||||
if ($get_info)
|
||||
@ -813,6 +821,13 @@ class fileupload
|
||||
}
|
||||
|
||||
$data .= $block;
|
||||
|
||||
// Cancel upload if we exceed timeout
|
||||
if ((time() - $upload_start) >= $this->upload_timeout)
|
||||
{
|
||||
$file = new fileerror($user->lang[$this->error_prefix . 'EMPTY_REMOTE_DATA']);
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user