diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-05-29 00:08:29 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-05-29 00:08:29 +0200 |
commit | 3ef9570d02d6a83082355e1f485a863a1bc4b431 (patch) | |
tree | 3432e690f90982fdf7bd2a41f867054550f9aa45 /lib/private/files/view.php | |
parent | 1af293dc136ffa46a454e7d8745265fd2bde89db (diff) | |
parent | a2e4bc8d33d0e7e3cc967db2857041e2817de4db (diff) | |
download | nextcloud-server-3ef9570d02d6a83082355e1f485a863a1bc4b431.tar.gz nextcloud-server-3ef9570d02d6a83082355e1f485a863a1bc4b431.zip |
Merge pull request #8547 from owncloud/path-length-master
Handling long paths properly in \OC\Files\View
Diffstat (limited to 'lib/private/files/view.php')
-rw-r--r-- | lib/private/files/view.php | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 940f31fe420..b698d87866c 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -29,14 +29,13 @@ use OC\Files\Cache\Updater; class View { private $fakeRoot = ''; - private $internal_path_cache = array(); - private $storage_cache = array(); public function __construct($root = '') { $this->fakeRoot = $root; } public function getAbsolutePath($path = '/') { + $this->assertPathLength($path); if ($path === '') { $path = '/'; } @@ -77,6 +76,7 @@ class View { * @return string */ public function getRelativePath($path) { + $this->assertPathLength($path); if ($this->fakeRoot == '') { return $path; } @@ -208,6 +208,7 @@ class View { } public function readfile($path) { + $this->assertPathLength($path); @ob_end_clean(); $handle = $this->fopen($path, 'rb'); if ($handle) { @@ -595,6 +596,7 @@ class View { } public function toTmpFile($path) { + $this->assertPathLength($path); if (Filesystem::isValidPath($path)) { $source = $this->fopen($path, 'r'); if ($source) { @@ -611,7 +613,7 @@ class View { } public function fromTmpFile($tmpFile, $path) { - + $this->assertPathLength($path); if (Filesystem::isValidPath($path)) { // Get directory that the file is going into @@ -640,6 +642,7 @@ class View { } public function getMimeType($path) { + $this->assertPathLength($path); return $this->basicOperation('getMimeType', $path); } @@ -669,6 +672,7 @@ class View { } public function free_space($path = '/') { + $this->assertPathLength($path); return $this->basicOperation('free_space', $path); } @@ -808,6 +812,7 @@ class View { * @return \OC\Files\FileInfo|false */ public function getFileInfo($path, $includeMountPoints = true) { + $this->assertPathLength($path); $data = array(); if (!Filesystem::isValidPath($path)) { return $data; @@ -878,6 +883,7 @@ class View { * @return FileInfo[] */ public function getDirectoryContent($directory, $mimetype_filter = '') { + $this->assertPathLength($directory); $result = array(); if (!Filesystem::isValidPath($directory)) { return $result; @@ -1006,6 +1012,7 @@ class View { * returns the fileid of the updated file */ public function putFileInfo($path, $data) { + $this->assertPathLength($path); if ($data instanceof FileInfo) { $data = $data->getData(); } @@ -1153,4 +1160,12 @@ class View { } return null; } + + private function assertPathLength($path) { + $maxLen = min(PHP_MAXPATHLEN, 4000); + $pathLen = strlen($path); + if ($pathLen > $maxLen) { + throw new \OCP\Files\InvalidPathException("Path length($pathLen) exceeds max path length($maxLen): $path"); + } + } } |