[Pkg-owncloud-commits] [owncloud] 16/104: reliable detect encrypted files

David Prévot taffit at moszumanska.debian.org
Sat Jan 18 13:33:36 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 2f0ec8256faed5dc8b17a5929578bd5b190a3f3a
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date:   Tue Dec 17 15:53:25 2013 +0100

    reliable detect encrypted files
---
 apps/files_encryption/lib/util.php | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index bf7c495..d4aa4d3 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -464,20 +464,22 @@ class Util {
 	 */
 	public function isEncryptedPath($path) {
 
-		$relPath = Helper::getPathToRealFile($path);
-
-		if ($relPath === false) {
-			$relPath = Helper::stripUserFilesPath($path);
-		}
-
-		$fileKey = Keymanager::getFileKey($this->view, $this, $relPath);
+		// Disable encryption proxy so data retrieved is in its
+		// original form
+		$proxyStatus = \OC_FileProxy::$enabled;
+		\OC_FileProxy::$enabled = false;
 
-		if ($fileKey === false) {
-			return false;
+		// we only need 24 byte from the last chunk
+		$data = '';
+		$handle = $this->view->fopen($path, 'r');
+		if (is_resource($handle) && !fseek($handle, -24, SEEK_END)) {
+			$data = fgets($handle);
 		}
 
-		return true;
+		// re-enable proxy
+		\OC_FileProxy::$enabled = $proxyStatus;
 
+		return Crypt::isCatfileContent($data);
 	}
 
 	/**

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