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 /lib | |
parent | ec3639dc7a28348b136d2008e692cffe8c3753ad (diff) | |
download | nextcloud-server-c01675de5d6650c7b1cd0571d8c313f21d13c33c.tar.gz nextcloud-server-c01675de5d6650c7b1cd0571d8c313f21d13c33c.zip |
more is_resource checks before readdir
Diffstat (limited to 'lib')
-rw-r--r-- | lib/files/storage/mappedlocal.php | 18 | ||||
-rw-r--r-- | lib/helper.php | 32 | ||||
-rw-r--r-- | lib/migration/content.php | 3 |
3 files changed, 30 insertions, 23 deletions
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 != '..' )) { |