[Pkg-owncloud-commits] [owncloud] 124/258: Added extra check to avoid deleting key folders

David Prévot taffit at moszumanska.debian.org
Sat Oct 11 17:22:28 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit 2b297567b584f9a347ee8a27c7f6011abb963029
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Fri Sep 19 19:01:02 2014 +0200

    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
---
 apps/files_trashbin/lib/trashbin.php | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php
index 4d2c53f..1edf51e 100644
--- a/apps/files_trashbin/lib/trashbin.php
+++ b/apps/files_trashbin/lib/trashbin.php
@@ -102,6 +102,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);
@@ -179,6 +185,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));
@@ -222,6 +232,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\Files\View('/'), $user);
 
 			// disable proxy to prevent recursive calls
@@ -403,6 +418,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 {
@@ -447,6 +468,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\Files\View('/'), $user);
 
 			if ($util->isSystemWideMountPoint($ownerPath)) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list