From a212c98125c956c35a72e966d72e720b0fd42376 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Tue, 30 Jul 2013 15:27:59 +0200 Subject: [PATCH] handle error if we can't handle the given path --- apps/files_encryption/lib/helper.php | 4 ++-- apps/files_encryption/lib/stream.php | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/files_encryption/lib/helper.php b/apps/files_encryption/lib/helper.php index f5a5d269a6..a9a78026d9 100755 --- a/apps/files_encryption/lib/helper.php +++ b/apps/files_encryption/lib/helper.php @@ -201,7 +201,7 @@ class Helper { $split = explode('/', $trimmed); // it is not a file relative to data/user/files - if ($split[1] !== 'files') { + if (count($split) < 3 || $split[1] !== 'files') { return false; } @@ -220,7 +220,7 @@ class Helper { $trimmed = ltrim($path, '/'); $split = explode('/', $trimmed); - if ($split[1] !== "files_versions") { + if (count($split) < 3 || $split[1] !== "files_versions") { return false; } diff --git a/apps/files_encryption/lib/stream.php b/apps/files_encryption/lib/stream.php index d9146e75b6..335ea3733e 100644 --- a/apps/files_encryption/lib/stream.php +++ b/apps/files_encryption/lib/stream.php @@ -107,6 +107,11 @@ class Stream { $this->relPath = Helper::getPathToRealFile($this->rawPath); } + if($this->relPath === false) { + \OCP\Util::writeLog('Encryption library', 'failed to open file "' . $this->rawPath . '" expecting a path to user/files or to user/files_versions', \OCP\Util::ERROR); + return false; + } + // Disable fileproxies so we can get the file size and open the source file without recursive encryption $proxyStatus = \OC_FileProxy::$enabled; \OC_FileProxy::$enabled = false;