]> source.dussan.org Git - nextcloud-server.git/commitdiff
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)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Tue, 12 Nov 2024 13:08:18 +0000 (13:08 +0000)
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 19c83b29bc8cb6bcb0567831dfaaa4cb1238db67..d3ad11d055c7fa94358967cd2dfe0b00bf7166ed 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 d19ef5cc02bc58cf6862abc01610d7b1ab38f8f3..2fc23c4ef3adefe3923d6f6aebfe24f421c7ed5a 100644 (file)
@@ -1145,7 +1145,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 2e6fcd9509991ce8d9fce7613b140fcc2dafe77f..fd447d3fa86a6b3cbc53e4c2d767b61ed8f4ee82 100644 (file)
@@ -230,7 +230,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 a646fd5fd0ba400548b5db6ac9315c4d1e3135d0..6c86c58a2721006295e794dd09596768f9200308 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;
                        }
@@ -113,7 +113,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;
                        }