Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-09-19 21:01:02 +0400
committerVincent Petry <pvince81@owncloud.com>2014-09-22 19:09:25 +0400
commite001dfb3be39ce4121060e883f81b5c41f6c23a6 (patch)
treec162370fd8424cdf7e3c9d8a086b0c9504b98d43 /apps/files_trashbin
parente123b6db6858af3bf1dafce494cf7d48eb6f7011 (diff)
Added extra check to avoid deleting key folders
Whenever a delete operation is called twice in a row, it could happen that the first call already deleted the file. The second call would return an empty $ownerPath because the file does not exist. That empty $ownerPath would run the key deletion operation on the wrong path. This fix adds checks in many places to make sure we don't use $ownerPath when it's empty or null. Backport of 8aca127e52f965871bea82cb27c6ea103baf34bb from master
Diffstat (limited to 'apps/files_trashbin')
-rw-r--r--apps/files_trashbin/lib/trashbin.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php
index 19bcec7acdb..6f24ae43421 100644
--- a/apps/files_trashbin/lib/trashbin.php
+++ b/apps/files_trashbin/lib/trashbin.php
@@ -97,6 +97,12 @@ class Trashbin {
$user = \OCP\User::getUser();
$size = 0;
list($owner, $ownerPath) = self::getUidAndFilename($file_path);
+
+ // file has been deleted in between
+ if (empty($ownerPath)) {
+ return false;
+ }
+
self::setUpTrash($user);
$view = new \OC\Files\View('/' . $user);
@@ -191,6 +197,10 @@ class Trashbin {
$rootView = new \OC\Files\View('/');
list($owner, $ownerPath) = self::getUidAndFilename($file_path);
+ // file has been deleted in between
+ if (empty($ownerPath)) {
+ return 0;
+ }
if ($rootView->is_dir($owner . '/files_versions/' . $ownerPath)) {
$size += self::calculateSize(new \OC\Files\View('/' . $owner . '/files_versions/' . $ownerPath));
@@ -234,6 +244,11 @@ class Trashbin {
list($owner, $ownerPath) = self::getUidAndFilename($file_path);
+ // file has been deleted in between
+ if (empty($ownerPath)) {
+ return 0;
+ }
+
$util = new \OCA\Encryption\Util(new \OC_FilesystemView('/'), $user);
// disable proxy to prevent recursive calls
@@ -433,6 +448,12 @@ class Trashbin {
list($owner, $ownerPath) = self::getUidAndFilename($target);
+ // file has been deleted in between
+ if (empty($ownerPath)) {
+ \OC_FileProxy::$enabled = $proxyStatus;
+ return false;
+ }
+
if ($timestamp) {
$versionedFile = $filename;
} else {
@@ -483,6 +504,11 @@ class Trashbin {
list($owner, $ownerPath) = self::getUidAndFilename($target);
+ // file has been deleted in between
+ if (empty($ownerPath)) {
+ return false;
+ }
+
$util = new \OCA\Encryption\Util(new \OC_FilesystemView('/'), $user);
if ($util->isSystemWideMountPoint($ownerPath)) {