diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2013-09-05 11:58:57 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2013-09-05 11:58:57 +0200 |
commit | c01675de5d6650c7b1cd0571d8c313f21d13c33c (patch) | |
tree | a1c3672af78c6e84d4e9fedab9cff0ef38620f2f /apps | |
parent | ec3639dc7a28348b136d2008e692cffe8c3753ad (diff) | |
download | nextcloud-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.php | 121 | ||||
-rwxr-xr-x | apps/files_external/lib/config.php | 2 | ||||
-rw-r--r-- | apps/files_sharing/lib/sharedstorage.php | 3 |
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) { |