]> 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:41:17 +0000 (09:11 +0530)
Signed-off-by: Josh Richards <josh.t.richards@gmail.com>
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 1ae9659cd59bf9cb0d86340b212a9e77168b3274..f25c3cb304be50bd66ec63e93015bf87165b860c 100644 (file)
@@ -228,7 +228,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;
                        }
@@ -494,7 +494,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 a8ecc363e64c2b8c5a6fb9642a171643e8c1f79a..fe16a3a9d69c2a949978974f63aede47087c6918 100644 (file)
@@ -1105,7 +1105,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 5ffac31d682896479069ca21ee89ebda85854a01..d4f3d1ddc847dd6042e66b9d5b25f3fce64fed8b 100644 (file)
@@ -192,7 +192,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 4b3e367da78f7d90457ff0d5570fee3caad02ca8..5fe396d97e1d191b29738dbbf8e68c586770b39b 100644 (file)
@@ -70,7 +70,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 0a170a0e7d53b46b38e8f19a1ec2495a9d2b0dfc..747cb4b6f4392682232af6a76a3896cbd47d1d79 100644 (file)
@@ -66,7 +66,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;
                        }
@@ -99,7 +99,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 bc9355d7bfb19a755b1b3430b375ed659bf3e464..ae6a6ece7426119fd001d469ef40a295e1743ae7 100644 (file)
@@ -208,7 +208,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 c48f52ecce7acea00fd10b8d81c71a32812395f2..fb2d05d0691719241bf0e120acea54bbf81d3961 100644 (file)
@@ -27,7 +27,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;
                        }