[Pkg-owncloud-commits] [owncloud] 37/59: files: storage: rename should check parent directories of old and new files

David Prévot taffit at moszumanska.debian.org
Fri Jul 18 16:19: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 a163b185ab03bd9816766250c6ae06df38625261
Author: Tigran Mkrtchyan <tigran.mkrtchyan at desy.de>
Date:   Thu Jul 10 10:54:26 2014 +0200

    files: storage: rename should check parent directories of old and new files
    
    as described by POSIX.1-2008
    (see http://pubs.opengroup.org/onlinepubs/9699919799/functions/rename.html)
    
    Signed-off-by: Tigran Mkrtchyan <tigran.mkrtchyan at desy.de>
---
 lib/private/files/storage/local.php       | 13 +++++++++++--
 lib/private/files/storage/mappedlocal.php | 13 +++++++++++--
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php
index e33747b..63570d7 100644
--- a/lib/private/files/storage/local.php
+++ b/lib/private/files/storage/local.php
@@ -172,10 +172,19 @@ if (\OC_Util::runningOnWindows()) {
 		}
 
 		public function rename($path1, $path2) {
-			if (!$this->isUpdatable($path1)) {
-				\OC_Log::write('core', 'unable to rename, file is not writable : ' . $path1, \OC_Log::ERROR);
+			$srcParent = dirname($path1);
+			$dstParent = dirname($path2);
+
+			if (!$this->isUpdatable($srcParent)) {
+				\OC_Log::write('core', 'unable to rename, source directory is not writable : ' . $srcParent, \OC_Log::ERROR);
 				return false;
 			}
+
+			if (!$this->isUpdatable($dstParent)) {
+				\OC_Log::write('core', 'unable to rename, destination directory is not writable : ' . $dstParent, \OC_Log::ERROR);
+				return false;
+			}
+
 			if (!$this->file_exists($path1)) {
 				\OC_Log::write('core', 'unable to rename, file does not exists : ' . $path1, \OC_Log::ERROR);
 				return false;
diff --git a/lib/private/files/storage/mappedlocal.php b/lib/private/files/storage/mappedlocal.php
index ea4deaa..6910eef 100644
--- a/lib/private/files/storage/mappedlocal.php
+++ b/lib/private/files/storage/mappedlocal.php
@@ -184,10 +184,19 @@ class MappedLocal extends \OC\Files\Storage\Common {
 	}
 
 	public function rename($path1, $path2) {
-		if (!$this->isUpdatable($path1)) {
-			\OC_Log::write('core', 'unable to rename, file is not writable : ' . $path1, \OC_Log::ERROR);
+		$srcParent = dirname($path1);
+		$dstParent = dirname($path2);
+
+		if (!$this->isUpdatable($srcParent)) {
+			\OC_Log::write('core', 'unable to rename, source directory is not writable : ' . $srcParent, \OC_Log::ERROR);
 			return false;
 		}
+
+		if (!$this->isUpdatable($dstParent)) {
+			\OC_Log::write('core', 'unable to rename, destination directory is not writable : ' . $dstParent, \OC_Log::ERROR);
+			return false;
+		}
+
 		if (!$this->file_exists($path1)) {
 			\OC_Log::write('core', 'unable to rename, file does not exists : ' . $path1, \OC_Log::ERROR);
 			return false;

-- 
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