]> source.dussan.org Git - nextcloud-server.git/commitdiff
Require minimum 1 MiB upload limit
authorRobin McCorkell <rmccorkell@karoshi.org.uk>
Fri, 27 Mar 2015 23:43:35 +0000 (23:43 +0000)
committerRobin McCorkell <rmccorkell@karoshi.org.uk>
Fri, 27 Mar 2015 23:43:35 +0000 (23:43 +0000)
lib/private/files.php

index e93b98a189171bb998e44644d41bdfe3dce15b26..0f48dca9715f2b0cb287e65cd89025ea6e1892f0 100644 (file)
@@ -52,6 +52,8 @@ class OC_Files {
        const ZIP_FILES = 2;
        const ZIP_DIR = 3;
 
+       const UPLOAD_MIN_LIMIT_BYTES = 1048576; // 1 MiB
+
        /**
         * @param string $filename
         * @param string $name
@@ -246,15 +248,17 @@ class OC_Files {
         * @return bool false on failure, size on success
         */
        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) {
                        //max size is always 1 byte lower than computerFileSize returns
                        if ($size > PHP_INT_MAX + 1)
                                return false;
                        $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
                if (intval($size) === 0) {