]> source.dussan.org Git - nextcloud-server.git/commitdiff
use strict equals in readdir loops to prevent issues with '0' files
authorRobin Appelman <icewind@owncloud.com>
Mon, 19 Aug 2013 10:04:53 +0000 (12:04 +0200)
committerRobin Appelman <icewind@owncloud.com>
Mon, 19 Aug 2013 10:04:53 +0000 (12:04 +0200)
14 files changed:
apps/files_external/lib/amazons3.php
apps/files_external/lib/google.php
apps/files_external/lib/irods.php
apps/files_external/lib/smb.php
apps/files_trashbin/index.php
lib/app.php
lib/archive.php
lib/cache/file.php
lib/cache/fileglobal.php
lib/connector/sabre/objecttree.php
lib/files/cache/scanner.php
lib/files/storage/common.php
lib/files/view.php
lib/installer.php

index 9363a350e27ae7d4040a58277866302348a9f455..2d7bcd4ac376b5d69f15f0899824e7d38fe6fee3 100644 (file)
@@ -183,7 +183,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
                }
 
                $dh = $this->opendir($path);
-               while ($file = readdir($dh)) {
+               while (($file = readdir($dh)) !== false) {
                        if ($file === '.' || $file === '..') {
                                continue;
                        }
@@ -464,7 +464,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
                        }
 
                        $dh = $this->opendir($path1);
-                       while ($file = readdir($dh)) {
+                       while (($file = readdir($dh)) !== false) {
                                if ($file === '.' || $file === '..') {
                                        continue;
                                }
index e6cdacdec4f8285a97af19c4cde22737b13c41ff..b27b9ae3f329043523ee14870cd478719dd87f4d 100644 (file)
@@ -206,7 +206,7 @@ class Google extends \OC\Files\Storage\Common {
        public function rmdir($path) {
                if (trim($path, '/') === '') {
                        $dir = $this->opendir($path);
-                       while ($file = readdir($dir)) {
+                       while (($file = readdir($dh)) !== false) {
                                if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
                                        if (!$this->unlink($path.'/'.$file)) {
                                                return false;
index a343ac5fb273129d0308d66c9a6cbe210746cd17..7ec3b3a0cfc09f32cfcb02aa289a5f73b7386386 100644 (file)
@@ -137,7 +137,7 @@ class iRODS extends \OC\Files\Storage\StreamWrapper{
        private function collectionMTime($path) {
                $dh = $this->opendir($path);
                $lastCTime = $this->filemtime($path);
-               while ($file = readdir($dh)) {
+               while (($file = readdir($dh)) !== false) {
                        if ($file != '.' and $file != '..') {
                                $time = $this->filemtime($file);
                                if ($time > $lastCTime) {
index 81a6c95638591115d7740496e313571fb35bbcf6..dc4e02731f1431ee8a66f6e94457bd7370f0bcf8 100644 (file)
@@ -99,7 +99,7 @@ class SMB extends \OC\Files\Storage\StreamWrapper{
        private function shareMTime() {
                $dh=$this->opendir('');
                $lastCtime=0;
-               while($file=readdir($dh)) {
+               while (($file = readdir($dh)) !== false) {
                        if ($file!='.' and $file!='..') {
                                $ctime=$this->filemtime($file);
                                if ($ctime>$lastCtime) {
index 2dbaefe7a78ebdca37331f3619f0a7db4e3b2bb1..27f8407db0641c13d5e803db502b62071f54b6df 100644 (file)
@@ -23,7 +23,7 @@ if ($dir) {
        $dirlisting = true;
        $dirContent = $view->opendir($dir);
        $i = 0;
-       while($entryName = readdir($dirContent)) {
+       while(($entryName = readdir($dirContent)) !== false) {
                if (!\OC\Files\Filesystem::isIgnoredDir($entryName)) {
                        $pos = strpos($dir.'/', '/', 1);
                        $tmp = substr($dir, 0, $pos);
index 5fa650044f3c46c6db179282c271b986c276dfad..f76b92cde1bd68cda417b0740023567c28d7290d 100644 (file)
@@ -666,7 +666,7 @@ class OC_App{
                        }
                        $dh = opendir( $apps_dir['path'] );
 
-                       while( $file = readdir( $dh ) ) {
+                       while (($file = readdir($dh)) !== false) {
 
                                if ($file[0] != '.' and is_file($apps_dir['path'].'/'.$file.'/appinfo/app.php')) {
 
index 70615db714e40e8bc230ad19c8e882feaf5c5f18..364cd5a74a1c9a880cef6400da70c0cc124c1ce5 100644 (file)
@@ -121,7 +121,7 @@ abstract class OC_Archive{
        function addRecursive($path, $source) {
                if($dh=opendir($source)) {
                        $this->addFolder($path);
-                       while($file=readdir($dh)) {
+                       while (($file = readdir($dh)) !== false) {
                                if($file=='.' or $file=='..') {
                                        continue;
                                }
index ba3dedaf8f3c16404fba969cf6e874ea04bc8563..9fee6034a714d34a250727af701a9b4fdf331098 100644 (file)
@@ -80,7 +80,7 @@ class OC_Cache_File{
                $storage = $this->getStorage();
                if($storage and $storage->is_dir('/')) {
                        $dh=$storage->opendir('/');
-                       while($file=readdir($dh)) {
+                       while (($file = readdir($dh)) !== false) {
                                if($file!='.' and $file!='..' and ($prefix==='' || strpos($file, $prefix) === 0)) {
                                        $storage->unlink('/'.$file);
                                }
@@ -94,7 +94,7 @@ class OC_Cache_File{
                if($storage and $storage->is_dir('/')) {
                        $now = time();
                        $dh=$storage->opendir('/');
-                       while($file=readdir($dh)) {
+                       while (($file = readdir($dh)) !== false) {
                                if($file!='.' and $file!='..') {
                                        $mtime = $storage->filemtime('/'.$file);
                                        if ($mtime < $now) {
index 6d01964e185605baa1a4d00de13accc0889ad43d..2fbd8ca3edbd0b5ae30cecda282ceecbf65ee207 100644 (file)
@@ -69,7 +69,7 @@ class OC_Cache_FileGlobal{
                $prefix = $this->fixKey($prefix);
                if($cache_dir and is_dir($cache_dir)) {
                        $dh=opendir($cache_dir);
-                       while($file=readdir($dh)) {
+                       while (($file = readdir($dh)) !== false) {
                                if($file!='.' and $file!='..' and ($prefix==='' || strpos($file, $prefix) === 0)) {
                                        unlink($cache_dir.$file);
                                }
@@ -88,7 +88,7 @@ class OC_Cache_FileGlobal{
                $cache_dir = self::getCacheDir();
                if($cache_dir and is_dir($cache_dir)) {
                        $dh=opendir($cache_dir);
-                       while($file=readdir($dh)) {
+                       while (($file = readdir($dh)) !== false) {
                                if($file!='.' and $file!='..') {
                                        $mtime = filemtime($cache_dir.$file);
                                        if ($mtime < $now) {
index c4ddcbecbb86e3f0ae6b0019f0d1ae5a52e259c1..b298813a202c6a5e62b5419f12ba22fb5048af9b 100644 (file)
@@ -88,7 +88,7 @@ class ObjectTree extends \Sabre_DAV_ObjectTree {
                } else {
                        Filesystem::mkdir($destination);
                        $dh = Filesystem::opendir($source);
-                       while ($subnode = readdir($dh)) {
+                       while (($subnode = readdir($dh)) !== false) {
 
                                if ($subnode == '.' || $subnode == '..') continue;
                                $this->copy($source . '/' . $subnode, $destination . '/' . $subnode);
index 597eabecf54532c2db0667478b082f37fa89de35..87fa7c1365a2ecd3fa2a805d28a83d5f1ead3006 100644 (file)
@@ -159,7 +159,7 @@ class Scanner extends BasicEmitter {
                $newChildren = array();
                if ($this->storage->is_dir($path) && ($dh = $this->storage->opendir($path))) {
                        \OC_DB::beginTransaction();
-                       while ($file = readdir($dh)) {
+                       while (($file = readdir($dh)) !== false) {
                                $child = ($path) ? $path . '/' . $file : $file;
                                if (!Filesystem::isIgnoredDir($file)) {
                                        $newChildren[] = $file;
index 3da13ac4df05306165b9f4a1e74908f468fcf7eb..1a273240eeb66aab1877c482c6e66637e3087d17 100644 (file)
@@ -142,7 +142,7 @@ abstract class Common implements \OC\Files\Storage\Storage {
                        return false;
                } else {
                        $directoryHandle = $this->opendir($directory);
-                       while ($contents = readdir($directoryHandle)) {
+                       while (($contents = readdir($directoryHandle)) !== false) {
                                if (!\OC\Files\Filesystem::isIgnoredDir($contents)) {
                                        $path = $directory . '/' . $contents;
                                        if ($this->is_dir($path)) {
@@ -225,7 +225,7 @@ abstract class Common implements \OC\Files\Storage\Storage {
 
        private function addLocalFolder($path, $target) {
                if ($dh = $this->opendir($path)) {
-                       while ($file = readdir($dh)) {
+                       while (($file = readdir($dh)) !== false) {
                                if ($file !== '.' and $file !== '..') {
                                        if ($this->is_dir($path . '/' . $file)) {
                                                mkdir($target . '/' . $file);
@@ -243,7 +243,7 @@ abstract class Common implements \OC\Files\Storage\Storage {
                $files = array();
                $dh = $this->opendir($dir);
                if ($dh) {
-                       while ($item = readdir($dh)) {
+                       while (($item = readdir($dh)) !== false) {
                                if ($item == '.' || $item == '..') continue;
                                if (strstr(strtolower($item), strtolower($query)) !== false) {
                                        $files[] = $dir . '/' . $item;
index c9727fe49841a0e48f8475cf0494fa4640aa09f1..bb737f19ef823695f8958492490ca2b50e092ba9 100644 (file)
@@ -499,7 +499,7 @@ class View {
                                } else {
                                        if ($this->is_dir($path1) && ($dh = $this->opendir($path1))) {
                                                $result = $this->mkdir($path2);
-                                               while ($file = readdir($dh)) {
+                                               while (($file = readdir($dh)) !== false) {
                                                        if (!Filesystem::isIgnoredDir($file)) {
                                                                $result = $this->copy($path1 . '/' . $file, $path2 . '/' . $file);
                                                        }
index dcd29f9e1ade6571e44f49f62c0aa1f14df1da7d..c29f9ec89821afe5f0b635cf387370795e8a33bc 100644 (file)
@@ -109,7 +109,7 @@ class OC_Installer{
                if(!is_file($extractDir.'/appinfo/info.xml')) {
                        //try to find it in a subdir
                        $dh=opendir($extractDir);
-                       while($folder=readdir($dh)) {
+                       while (($folder = readdir($dh)) !== false) {
                                if($folder[0]!='.' and is_dir($extractDir.'/'.$folder)) {
                                        if(is_file($extractDir.'/'.$folder.'/appinfo/info.xml')) {
                                                $extractDir.='/'.$folder;