summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files_encryption/lib/util.php121
-rwxr-xr-xapps/files_external/lib/config.php2
-rw-r--r--apps/files_sharing/lib/sharedstorage.php3
-rw-r--r--lib/files/storage/mappedlocal.php18
-rw-r--r--lib/helper.php32
-rw-r--r--lib/migration/content.php3
6 files changed, 94 insertions, 85 deletions
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index b8d68623493..8a7b6f40cba 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -329,72 +329,73 @@ class Util {
$this->view->is_dir($directory)
&& $handle = $this->view->opendir($directory)
) {
-
- while (false !== ($file = readdir($handle))) {
-
- if (
- $file !== "."
- && $file !== ".."
- ) {
-
- $filePath = $directory . '/' . $this->view->getRelativePath('/' . $file);
- $relPath = \OCA\Encryption\Helper::stripUserFilesPath($filePath);
-
- // If the path is a directory, search
- // its contents
- if ($this->view->is_dir($filePath)) {
-
- $this->findEncFiles($filePath, $found);
-
- // If the path is a file, determine
- // its encryption status
- } elseif ($this->view->is_file($filePath)) {
-
- // Disable proxies again, some-
- // where they got re-enabled :/
- \OC_FileProxy::$enabled = false;
-
- $isEncryptedPath = $this->isEncryptedPath($filePath);
- // If the file is encrypted
- // NOTE: If the userId is
- // empty or not set, file will
- // detected as plain
- // NOTE: This is inefficient;
- // scanning every file like this
- // will eat server resources :(
- if (
- Keymanager::getFileKey($this->view, $this->userId, $relPath)
- && $isEncryptedPath
- ) {
-
- $found['encrypted'][] = array(
- 'name' => $file,
- 'path' => $filePath
- );
-
- // If the file uses old
- // encryption system
- } elseif (Crypt::isLegacyEncryptedContent($isEncryptedPath, $relPath)) {
-
- $found['legacy'][] = array(
- 'name' => $file,
- 'path' => $filePath
- );
-
- // If the file is not encrypted
- } else {
-
- $found['plain'][] = array(
- 'name' => $file,
- 'path' => $relPath
- );
+ if(is_resource($handle)) {
+ while (false !== ($file = readdir($handle))) {
+
+ if (
+ $file !== "."
+ && $file !== ".."
+ ) {
+
+ $filePath = $directory . '/' . $this->view->getRelativePath('/' . $file);
+ $relPath = \OCA\Encryption\Helper::stripUserFilesPath($filePath);
+
+ // If the path is a directory, search
+ // its contents
+ if ($this->view->is_dir($filePath)) {
+
+ $this->findEncFiles($filePath, $found);
+
+ // If the path is a file, determine
+ // its encryption status
+ } elseif ($this->view->is_file($filePath)) {
+
+ // Disable proxies again, some-
+ // where they got re-enabled :/
+ \OC_FileProxy::$enabled = false;
+
+ $isEncryptedPath = $this->isEncryptedPath($filePath);
+ // If the file is encrypted
+ // NOTE: If the userId is
+ // empty or not set, file will
+ // detected as plain
+ // NOTE: This is inefficient;
+ // scanning every file like this
+ // will eat server resources :(
+ if (
+ Keymanager::getFileKey($this->view, $this->userId, $relPath)
+ && $isEncryptedPath
+ ) {
+
+ $found['encrypted'][] = array(
+ 'name' => $file,
+ 'path' => $filePath
+ );
+
+ // If the file uses old
+ // encryption system
+ } elseif (Crypt::isLegacyEncryptedContent($isEncryptedPath, $relPath)) {
+
+ $found['legacy'][] = array(
+ 'name' => $file,
+ 'path' => $filePath
+ );
+
+ // If the file is not encrypted
+ } else {
+
+ $found['plain'][] = array(
+ 'name' => $file,
+ 'path' => $relPath
+ );
+
+ }
}
}
}
-
}
\OC_FileProxy::$enabled = true;
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index 1935740cd2e..659959e662e 100755
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -378,7 +378,7 @@ class OC_Mount_Config {
}
$result = array();
$handle = opendir($path);
- if ( ! $handle) {
+ if(!is_resource($handle)) {
return array();
}
while (false !== ($file = readdir($handle))) {
diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php
index d91acbbb2bd..257da89c84e 100644
--- a/apps/files_sharing/lib/sharedstorage.php
+++ b/apps/files_sharing/lib/sharedstorage.php
@@ -221,7 +221,8 @@ class Shared extends \OC\Files\Storage\Common {
public function filemtime($path) {
if ($path == '' || $path == '/') {
$mtime = 0;
- if ($dh = $this->opendir($path)) {
+ $dh = $this->opendir($path);
+ if(is_resource($dh)) {
while (($filename = readdir($dh)) !== false) {
$tempmtime = $this->filemtime($filename);
if ($tempmtime > $mtime) {
diff --git a/lib/files/storage/mappedlocal.php b/lib/files/storage/mappedlocal.php
index fbf1b4ebf96..ba5ac4191c5 100644
--- a/lib/files/storage/mappedlocal.php
+++ b/lib/files/storage/mappedlocal.php
@@ -65,16 +65,18 @@ class MappedLocal extends \OC\Files\Storage\Common{
$logicalPath = $this->mapper->physicalToLogic($physicalPath);
$dh = opendir($physicalPath);
- while (($file = readdir($dh)) !== false) {
- if ($file === '.' or $file === '..') {
- continue;
- }
+ if(is_resource($dh)) {
+ while (($file = readdir($dh)) !== false) {
+ if ($file === '.' or $file === '..') {
+ continue;
+ }
- $logicalFilePath = $this->mapper->physicalToLogic($physicalPath.'/'.$file);
+ $logicalFilePath = $this->mapper->physicalToLogic($physicalPath.'/'.$file);
- $file= $this->mapper->stripRootFolder($logicalFilePath, $logicalPath);
- $file = $this->stripLeading($file);
- $files[]= $file;
+ $file= $this->mapper->stripRootFolder($logicalFilePath, $logicalPath);
+ $file = $this->stripLeading($file);
+ $files[]= $file;
+ }
}
\OC\Files\Stream\Dir::register('local-win32'.$path, $files);
diff --git a/lib/helper.php b/lib/helper.php
index 5fb8fed3459..0af7f6f0394 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -341,17 +341,19 @@ class OC_Helper {
if (!is_dir($path))
return chmod($path, $filemode);
$dh = opendir($path);
- while (($file = readdir($dh)) !== false) {
- if ($file != '.' && $file != '..') {
- $fullpath = $path . '/' . $file;
- if (is_link($fullpath))
- return false;
- elseif (!is_dir($fullpath) && !@chmod($fullpath, $filemode))
- return false; elseif (!self::chmodr($fullpath, $filemode))
- return false;
+ if(is_resource($dh)) {
+ while (($file = readdir($dh)) !== false) {
+ if ($file != '.' && $file != '..') {
+ $fullpath = $path . '/' . $file;
+ if (is_link($fullpath))
+ return false;
+ elseif (!is_dir($fullpath) && !@chmod($fullpath, $filemode))
+ return false; elseif (!self::chmodr($fullpath, $filemode))
+ return false;
+ }
}
+ closedir($dh);
}
- closedir($dh);
if (@chmod($path, $filemode))
return true;
else
@@ -649,9 +651,11 @@ class OC_Helper {
// if oc-noclean is empty delete it
$isTmpDirNoCleanEmpty = true;
$tmpDirNoClean = opendir($tmpDirNoCleanName);
- while (false !== ($file = readdir($tmpDirNoClean))) {
- if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
- $isTmpDirNoCleanEmpty = false;
+ if(is_resource($tmpDirNoClean)) {
+ while (false !== ($file = readdir($tmpDirNoClean))) {
+ if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
+ $isTmpDirNoCleanEmpty = false;
+ }
}
}
if ($isTmpDirNoCleanEmpty) {
@@ -694,7 +698,7 @@ class OC_Helper {
$newpath = $path . '/' . $filename;
if ($view->file_exists($newpath)) {
if (preg_match_all('/\((\d+)\)/', $name, $matches, PREG_OFFSET_CAPTURE)) {
- //Replace the last "(number)" with "(number+1)"
+ //Replace the last "(number)" with "(number+1)"
$last_match = count($matches[0]) - 1;
$counter = $matches[1][$last_match][0] + 1;
$offset = $matches[0][$last_match][1];
@@ -705,7 +709,7 @@ class OC_Helper {
}
do {
if ($offset) {
- //Replace the last "(number)" with "(number+1)"
+ //Replace the last "(number)" with "(number+1)"
$newname = substr_replace($name, '(' . $counter . ')', $offset, $match_length);
} else {
$newname = $name . ' (' . $counter . ')';
diff --git a/lib/migration/content.php b/lib/migration/content.php
index 2d8268a1d74..4413d722731 100644
--- a/lib/migration/content.php
+++ b/lib/migration/content.php
@@ -191,7 +191,8 @@ class OC_Migration_Content{
if( !file_exists( $dir ) ) {
return false;
}
- if ($dirhandle = opendir($dir)) {
+ $dirhandle = opendir($dir);
+ if(is_resource($dirhandle)) {
while (false !== ( $file = readdir($dirhandle))) {
if (( $file != '.' ) && ( $file != '..' )) {