summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2013-09-05 11:58:57 +0200
committerArthur Schiwon <blizzz@owncloud.com>2013-09-05 11:58:57 +0200
commitc01675de5d6650c7b1cd0571d8c313f21d13c33c (patch)
treea1c3672af78c6e84d4e9fedab9cff0ef38620f2f /apps
parentec3639dc7a28348b136d2008e692cffe8c3753ad (diff)
downloadnextcloud-server-c01675de5d6650c7b1cd0571d8c313f21d13c33c.tar.gz
nextcloud-server-c01675de5d6650c7b1cd0571d8c313f21d13c33c.zip
more is_resource checks before readdir
Diffstat (limited to 'apps')
-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
3 files changed, 64 insertions, 62 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) {