diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2013-09-04 13:06:04 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2013-09-04 13:06:04 +0200 |
commit | ec3639dc7a28348b136d2008e692cffe8c3753ad (patch) | |
tree | 3d197d325496925be0ddee1f1ab22c48c7c817a1 /apps/files_trashbin | |
parent | 09187f3b3b30e6f810c6afff7332615ed472154e (diff) | |
download | nextcloud-server-ec3639dc7a28348b136d2008e692cffe8c3753ad.tar.gz nextcloud-server-ec3639dc7a28348b136d2008e692cffe8c3753ad.zip |
Always check variable type before using readdir to avoid surprises
Diffstat (limited to 'apps/files_trashbin')
-rw-r--r-- | apps/files_trashbin/index.php | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/apps/files_trashbin/index.php b/apps/files_trashbin/index.php index 0baeab1de97..0dd6944281c 100644 --- a/apps/files_trashbin/index.php +++ b/apps/files_trashbin/index.php @@ -23,23 +23,24 @@ if ($dir) { $dirlisting = true; $dirContent = $view->opendir($dir); $i = 0; - while(($entryName = readdir($dirContent)) !== false) { - if (!\OC\Files\Filesystem::isIgnoredDir($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 (!\OC\Files\Filesystem::isIgnoredDir($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; $query = \OC_DB::prepare('SELECT `id`,`location`,`timestamp`,`type`,`mime` FROM `*PREFIX*files_trash` WHERE `user` = ?'); |