Commit d3752ca1 authored by Vincent Petry's avatar Vincent Petry
Browse files

Merge pull request #15289 from owncloud/min-upload-limit

Require minimum 1 MiB upload limit
parents 3f891c26 ab991458
...@@ -52,6 +52,8 @@ class OC_Files { ...@@ -52,6 +52,8 @@ class OC_Files {
const ZIP_FILES = 2; const ZIP_FILES = 2;
const ZIP_DIR = 3; const ZIP_DIR = 3;
const UPLOAD_MIN_LIMIT_BYTES = 1048576; // 1 MiB
/** /**
* @param string $filename * @param string $filename
* @param string $name * @param string $name
...@@ -246,15 +248,17 @@ class OC_Files { ...@@ -246,15 +248,17 @@ class OC_Files {
* @return bool false on failure, size on success * @return bool false on failure, size on success
*/ */
static function setUploadLimit($size) { static function setUploadLimit($size) {
//don't allow user to break his config -- upper boundary //don't allow user to break his config
if ($size > PHP_INT_MAX) { if ($size > PHP_INT_MAX) {
//max size is always 1 byte lower than computerFileSize returns //max size is always 1 byte lower than computerFileSize returns
if ($size > PHP_INT_MAX + 1) if ($size > PHP_INT_MAX + 1)
return false; return false;
$size -= 1; $size -= 1;
} else {
$size = OC_Helper::phpFileSize($size);
} }
if ($size < self::UPLOAD_MIN_LIMIT_BYTES) {
return false;
}
$size = OC_Helper::phpFileSize($size);
//don't allow user to break his config -- broken or malicious size input //don't allow user to break his config -- broken or malicious size input
if (intval($size) === 0) { if (intval($size) === 0) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment