]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix: Clean-up some remaining readdir calls with undesirable false evaluation potential
authorJosh Richards <josh.t.richards@gmail.com>
Sat, 3 Jun 2023 12:57:38 +0000 (08:57 -0400)
committeryemkareems <yemkareems@gmail.com>
Wed, 13 Nov 2024 03:04:23 +0000 (08:34 +0530)
Signed-off-by: Josh Richards <josh.t.richards@gmail.com>
[skip ci]

apps/files_external/lib/Lib/Storage/Swift.php
apps/files_trashbin/lib/Trashbin.php
lib/private/Files/Storage/Common.php
lib/private/Files/Storage/PolyFill/CopyDirectory.php
tests/lib/Files/Storage/Storage.php
tests/lib/Files/Storage/Wrapper/EncodingTest.php
tests/lib/Files/Storage/Wrapper/JailTest.php

index 7283e5ae7b12a5d68fcad87fc72492e9534de7cf..d7b9d27f4088451a4c855d5834c73159bca262ba 100644 (file)
@@ -261,7 +261,7 @@ class Swift extends \OC\Files\Storage\Common {
                }
 
                $dh = $this->opendir($path);
-               while ($file = readdir($dh)) {
+               while (($file = readdir($dh)) !== false) {
                        if (\OC\Files\Filesystem::isIgnoredDir($file)) {
                                continue;
                        }
@@ -527,7 +527,7 @@ class Swift extends \OC\Files\Storage\Common {
                        }
 
                        $dh = $this->opendir($source);
-                       while ($file = readdir($dh)) {
+                       while (($file = readdir($dh)) !== false) {
                                if (\OC\Files\Filesystem::isIgnoredDir($file)) {
                                        continue;
                                }
index 575a0928c90025c0f2a342a3dc34f72126316f8a..1d29ce2aa608fffbff1472c7fc5ccc9700217c2b 100644 (file)
@@ -1141,7 +1141,7 @@ class Trashbin {
        public static function isEmpty($user) {
                $view = new View('/' . $user . '/files_trashbin');
                if ($view->is_dir('/files') && $dh = $view->opendir('/files')) {
-                       while ($file = readdir($dh)) {
+                       while (($file = readdir($dh)) !== false) {
                                if (!Filesystem::isIgnoredDir($file)) {
                                        return false;
                                }
index ab9cd5c33261b11e26e0223bf9317d315ca712fa..d2a344a8217aa5511522486e4e9d138f94d28792 100644 (file)
@@ -232,7 +232,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
                        $this->remove($target);
                        $dir = $this->opendir($source);
                        $this->mkdir($target);
-                       while ($file = readdir($dir)) {
+                       while (($file = readdir($dir)) !== false) {
                                if (!Filesystem::isIgnoredDir($file)) {
                                        if (!$this->copy($source . '/' . $file, $target . '/' . $file)) {
                                                closedir($dir);
index ff05eecb134ce712a5b2bb2f64511953ae953505..c22b9edc592d1f1a693ff4f2a35d2a63f1ed4a84 100644 (file)
@@ -86,7 +86,7 @@ trait CopyDirectory {
        protected function copyRecursive($source, $target) {
                $dh = $this->opendir($source);
                $result = true;
-               while ($file = readdir($dh)) {
+               while (($file = readdir($dh)) !== false) {
                        if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
                                if ($this->is_dir($source . '/' . $file)) {
                                        $this->mkdir($target . '/' . $file);
index 63b3dfc5a984322218293861c5d864909245833d..7e9af7197971f5c170ff1cbdb7bb90e71d0d23a4 100644 (file)
@@ -81,7 +81,7 @@ abstract class Storage extends \Test\TestCase {
 
                $dh = $this->instance->opendir('/');
                $content = [];
-               while ($file = readdir($dh)) {
+               while (($file = readdir($dh)) !== false) {
                        if ($file != '.' and $file != '..') {
                                $content[] = $file;
                        }
@@ -114,7 +114,7 @@ abstract class Storage extends \Test\TestCase {
 
                $dh = $this->instance->opendir('/');
                $content = [];
-               while ($file = readdir($dh)) {
+               while (($file = readdir($dh)) !== false) {
                        if ($file != '.' and $file != '..') {
                                $content[] = $file;
                        }
index 0901edf83fa06811f4b173d7ff9f4e831c0229f8..3f14ec64995162b730420a6e66e0572b220a8ad5 100644 (file)
@@ -209,7 +209,7 @@ class EncodingTest extends \Test\Files\Storage\Storage {
 
                $dh = $this->instance->opendir('/test');
                $content = [];
-               while ($file = readdir($dh)) {
+               while (($file = readdir($dh)) !== false) {
                        if ($file != '.' and $file != '..') {
                                $content[] = $file;
                        }
index 148bd3a4f30c21b8414742b9a800ea21bce4fed7..01fd67ddfb869c627e9d6690aa3afa8c5549bdf6 100644 (file)
@@ -28,7 +28,7 @@ class JailTest extends \Test\Files\Storage\Storage {
                // test that nothing outside our jail is touched
                $contents = [];
                $dh = $this->sourceStorage->opendir('');
-               while ($file = readdir($dh)) {
+               while (($file = readdir($dh)) !== false) {
                        if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
                                $contents[] = $file;
                        }