summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2013-09-02 18:58:25 +0200
committerArthur Schiwon <blizzz@owncloud.com>2013-09-02 18:58:25 +0200
commitcd6443a19fd68e0376f4f1b82ac215328eca0c41 (patch)
tree58e768b0bed38048cb635482a330a31a153f37e0 /apps
parente1d6e63083cc5ff31cd974e3b7196793cbeebc99 (diff)
downloadnextcloud-server-cd6443a19fd68e0376f4f1b82ac215328eca0c41.tar.gz
nextcloud-server-cd6443a19fd68e0376f4f1b82ac215328eca0c41.zip
Check variable type before using readdir to avoid surprises and fix #4667 #4658 and #4613
Diffstat (limited to 'apps')
-rw-r--r--apps/files_external/lib/google.php12
-rw-r--r--apps/files_external/lib/irods.php14
-rw-r--r--apps/files_external/lib/smb.php12
-rw-r--r--apps/files_trashbin/index.php30
4 files changed, 38 insertions, 30 deletions
diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php
index b27b9ae3f32..9f3fef8c61f 100644
--- a/apps/files_external/lib/google.php
+++ b/apps/files_external/lib/google.php
@@ -206,14 +206,16 @@ class Google extends \OC\Files\Storage\Common {
public function rmdir($path) {
if (trim($path, '/') === '') {
$dir = $this->opendir($path);
- while (($file = readdir($dh)) !== false) {
- if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
- if (!$this->unlink($path.'/'.$file)) {
- return false;
+ if(is_resource($dir)) {
+ while (($file = readdir($dir)) !== false) {
+ if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
+ if (!$this->unlink($path.'/'.$file)) {
+ return false;
+ }
}
}
+ closedir($dir);
}
- closedir($dir);
$this->driveFiles = array();
return true;
} else {
diff --git a/apps/files_external/lib/irods.php b/apps/files_external/lib/irods.php
index 7ec3b3a0cfc..f7279a6c5d2 100644
--- a/apps/files_external/lib/irods.php
+++ b/apps/files_external/lib/irods.php
@@ -55,7 +55,7 @@ class iRODS extends \OC\Files\Storage\StreamWrapper{
} else {
throw new \Exception();
}
-
+
}
public static function login( $params ) {
@@ -137,11 +137,13 @@ class iRODS extends \OC\Files\Storage\StreamWrapper{
private function collectionMTime($path) {
$dh = $this->opendir($path);
$lastCTime = $this->filemtime($path);
- while (($file = readdir($dh)) !== false) {
- if ($file != '.' and $file != '..') {
- $time = $this->filemtime($file);
- if ($time > $lastCTime) {
- $lastCTime = $time;
+ if(is_resource($dh)) {
+ while (($file = readdir($dh)) !== false) {
+ if ($file != '.' and $file != '..') {
+ $time = $this->filemtime($file);
+ if ($time > $lastCTime) {
+ $lastCTime = $time;
+ }
}
}
}
diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php
index dd265cada1c..fede9fe392f 100644
--- a/apps/files_external/lib/smb.php
+++ b/apps/files_external/lib/smb.php
@@ -89,11 +89,13 @@ class SMB extends \OC\Files\Storage\StreamWrapper{
private function shareMTime() {
$dh=$this->opendir('');
$lastCtime=0;
- while (($file = readdir($dh)) !== false) {
- if ($file!='.' and $file!='..') {
- $ctime=$this->filemtime($file);
- if ($ctime>$lastCtime) {
- $lastCtime=$ctime;
+ if(is_resource($dh)) {
+ while (($file = readdir($dh)) !== false) {
+ if ($file!='.' and $file!='..') {
+ $ctime=$this->filemtime($file);
+ if ($ctime>$lastCtime) {
+ $lastCtime=$ctime;
+ }
}
}
}
diff --git a/apps/files_trashbin/index.php b/apps/files_trashbin/index.php
index 72a9c2bbcb0..da5e09e0fab 100644
--- a/apps/files_trashbin/index.php
+++ b/apps/files_trashbin/index.php
@@ -23,22 +23,24 @@ if ($dir) {
$dirlisting = true;
$dirContent = $view->opendir($dir);
$i = 0;
- while(($entryName = readdir($dirContent)) !== false) {
- if ( $entryName != '.' && $entryName != '..' ) {
- $pos = strpos($dir.'/', '/', 1);
- $tmp = substr($dir, 0, $pos);
- $pos = strrpos($tmp, '.d');
- $timestamp = substr($tmp, $pos+2);
- $result[] = array(
- 'id' => $entryName,
- 'timestamp' => $timestamp,
- 'mime' => $view->getMimeType($dir.'/'.$entryName),
- 'type' => $view->is_dir($dir.'/'.$entryName) ? 'dir' : 'file',
- 'location' => $dir,
- );
+ if(is_resource($dirContent)) {
+ while(($entryName = readdir($dirContent)) !== false) {
+ if ( $entryName != '.' && $entryName != '..' ) {
+ $pos = strpos($dir.'/', '/', 1);
+ $tmp = substr($dir, 0, $pos);
+ $pos = strrpos($tmp, '.d');
+ $timestamp = substr($tmp, $pos+2);
+ $result[] = array(
+ 'id' => $entryName,
+ 'timestamp' => $timestamp,
+ 'mime' => $view->getMimeType($dir.'/'.$entryName),
+ 'type' => $view->is_dir($dir.'/'.$entryName) ? 'dir' : 'file',
+ 'location' => $dir,
+ );
+ }
}
+ closedir($dirContent);
}
- closedir($dirContent);
} else {
$dirlisting = false;