summaryrefslogtreecommitdiffstats
path: root/lib/files/storage
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2013-09-04 13:06:04 +0200
committerArthur Schiwon <blizzz@owncloud.com>2013-09-04 13:06:04 +0200
commitec3639dc7a28348b136d2008e692cffe8c3753ad (patch)
tree3d197d325496925be0ddee1f1ab22c48c7c817a1 /lib/files/storage
parent09187f3b3b30e6f810c6afff7332615ed472154e (diff)
downloadnextcloud-server-ec3639dc7a28348b136d2008e692cffe8c3753ad.tar.gz
nextcloud-server-ec3639dc7a28348b136d2008e692cffe8c3753ad.zip
Always check variable type before using readdir to avoid surprises
Diffstat (limited to 'lib/files/storage')
-rw-r--r--lib/files/storage/common.php21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/files/storage/common.php b/lib/files/storage/common.php
index 01560f34fde..a5b79f0e967 100644
--- a/lib/files/storage/common.php
+++ b/lib/files/storage/common.php
@@ -142,13 +142,15 @@ abstract class Common implements \OC\Files\Storage\Storage {
return false;
} else {
$directoryHandle = $this->opendir($directory);
- while (($contents = readdir($directoryHandle)) !== false) {
- if (!\OC\Files\Filesystem::isIgnoredDir($contents)) {
- $path = $directory . '/' . $contents;
- if ($this->is_dir($path)) {
- $this->deleteAll($path);
- } else {
- $this->unlink($path);
+ if(is_resource($directoryHandle)) {
+ while (($contents = readdir($directoryHandle)) !== false) {
+ if (!\OC\Files\Filesystem::isIgnoredDir($contents)) {
+ $path = $directory . '/' . $contents;
+ if ($this->is_dir($path)) {
+ $this->deleteAll($path);
+ } else {
+ $this->unlink($path);
+ }
}
}
}
@@ -224,7 +226,8 @@ abstract class Common implements \OC\Files\Storage\Storage {
}
private function addLocalFolder($path, $target) {
- if ($dh = $this->opendir($path)) {
+ $dh = $this->opendir($path);
+ if(is_resource($dh)) {
while (($file = readdir($dh)) !== false) {
if ($file !== '.' and $file !== '..') {
if ($this->is_dir($path . '/' . $file)) {
@@ -242,7 +245,7 @@ abstract class Common implements \OC\Files\Storage\Storage {
protected function searchInDir($query, $dir = '') {
$files = array();
$dh = $this->opendir($dir);
- if ($dh) {
+ if (is_resource($dh)) {
while (($item = readdir($dh)) !== false) {
if ($item == '.' || $item == '..') continue;
if (strstr(strtolower($item), strtolower($query)) !== false) {