diff options
author | Robin Appelman <robin@icewind.nl> | 2019-06-27 11:10:08 +0200 |
---|---|---|
committer | Backportbot <backportbot-noreply@rullzer.com> | 2019-06-27 14:40:13 +0000 |
commit | 48a0065d2d6aaf9af1afaf9060f555a090c67109 (patch) | |
tree | 9306b232c5f99629070b170451e1bc1b23163ee9 /lib | |
parent | 7c39bfe19d5410404b939618eece01a7c4fe4951 (diff) | |
download | nextcloud-server-48a0065d2d6aaf9af1afaf9060f555a090c67109.tar.gz nextcloud-server-48a0065d2d6aaf9af1afaf9060f555a090c67109.zip |
verify that paths are valid for recursive local move
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Files/Storage/Local.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php index 46b53dcf95c..18689cdfd28 100644 --- a/lib/private/Files/Storage/Local.php +++ b/lib/private/Files/Storage/Local.php @@ -39,6 +39,7 @@ namespace OC\Files\Storage; +use OC\Files\Filesystem; use OC\Files\Storage\Wrapper\Jail; use OCP\Files\ForbiddenException; use OCP\Files\Storage\IStorage; @@ -231,6 +232,18 @@ class Local extends \OC\Files\Storage\Common { } + private function treeContainsBlacklistedFile(string $path): bool { + $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path)); + foreach ($iterator as $file) { + /** @var \SplFileInfo $file */ + if (Filesystem::isFileBlacklisted($file->getBasename())) { + return true; + } + } + + return false; + } + public function rename($path1, $path2) { $srcParent = dirname($path1); $dstParent = dirname($path2); @@ -267,6 +280,10 @@ class Local extends \OC\Files\Storage\Common { } return $result; } + + if ($this->treeContainsBlacklistedFile($this->getSourcePath($path1))) { + throw new ForbiddenException('Invalid path', false); + } } return rename($this->getSourcePath($path1), $this->getSourcePath($path2)); @@ -362,6 +379,10 @@ class Local extends \OC\Files\Storage\Common { * @throws ForbiddenException */ public function getSourcePath($path) { + if (Filesystem::isFileBlacklisted($path)) { + throw new ForbiddenException('Invalid path', false); + } + $fullPath = $this->datadir . $path; $currentPath = $path; if ($this->allowSymlinks || $currentPath === '') { |