more is_resource checks before readdir
This commit is contained in:
parent
ec3639dc7a
commit
c01675de5d
|
@ -329,72 +329,73 @@ class Util {
|
||||||
$this->view->is_dir($directory)
|
$this->view->is_dir($directory)
|
||||||
&& $handle = $this->view->opendir($directory)
|
&& $handle = $this->view->opendir($directory)
|
||||||
) {
|
) {
|
||||||
|
if(is_resource($handle)) {
|
||||||
|
while (false !== ($file = readdir($handle))) {
|
||||||
|
|
||||||
while (false !== ($file = readdir($handle))) {
|
if (
|
||||||
|
$file !== "."
|
||||||
|
&& $file !== ".."
|
||||||
|
) {
|
||||||
|
|
||||||
if (
|
$filePath = $directory . '/' . $this->view->getRelativePath('/' . $file);
|
||||||
$file !== "."
|
$relPath = \OCA\Encryption\Helper::stripUserFilesPath($filePath);
|
||||||
&& $file !== ".."
|
|
||||||
) {
|
|
||||||
|
|
||||||
$filePath = $directory . '/' . $this->view->getRelativePath('/' . $file);
|
// If the path is a directory, search
|
||||||
$relPath = \OCA\Encryption\Helper::stripUserFilesPath($filePath);
|
// its contents
|
||||||
|
if ($this->view->is_dir($filePath)) {
|
||||||
|
|
||||||
// If the path is a directory, search
|
$this->findEncFiles($filePath, $found);
|
||||||
// its contents
|
|
||||||
if ($this->view->is_dir($filePath)) {
|
|
||||||
|
|
||||||
$this->findEncFiles($filePath, $found);
|
// If the path is a file, determine
|
||||||
|
// its encryption status
|
||||||
|
} elseif ($this->view->is_file($filePath)) {
|
||||||
|
|
||||||
// If the path is a file, determine
|
// Disable proxies again, some-
|
||||||
// its encryption status
|
// where they got re-enabled :/
|
||||||
} elseif ($this->view->is_file($filePath)) {
|
\OC_FileProxy::$enabled = false;
|
||||||
|
|
||||||
// Disable proxies again, some-
|
$isEncryptedPath = $this->isEncryptedPath($filePath);
|
||||||
// where they got re-enabled :/
|
// If the file is encrypted
|
||||||
\OC_FileProxy::$enabled = false;
|
// NOTE: If the userId is
|
||||||
|
// empty or not set, file will
|
||||||
|
// detected as plain
|
||||||
|
// NOTE: This is inefficient;
|
||||||
|
// scanning every file like this
|
||||||
|
// will eat server resources :(
|
||||||
|
if (
|
||||||
|
Keymanager::getFileKey($this->view, $this->userId, $relPath)
|
||||||
|
&& $isEncryptedPath
|
||||||
|
) {
|
||||||
|
|
||||||
$isEncryptedPath = $this->isEncryptedPath($filePath);
|
$found['encrypted'][] = array(
|
||||||
// If the file is encrypted
|
'name' => $file,
|
||||||
// NOTE: If the userId is
|
'path' => $filePath
|
||||||
// empty or not set, file will
|
);
|
||||||
// detected as plain
|
|
||||||
// NOTE: This is inefficient;
|
|
||||||
// scanning every file like this
|
|
||||||
// will eat server resources :(
|
|
||||||
if (
|
|
||||||
Keymanager::getFileKey($this->view, $this->userId, $relPath)
|
|
||||||
&& $isEncryptedPath
|
|
||||||
) {
|
|
||||||
|
|
||||||
$found['encrypted'][] = array(
|
// If the file uses old
|
||||||
'name' => $file,
|
// encryption system
|
||||||
'path' => $filePath
|
} elseif (Crypt::isLegacyEncryptedContent($isEncryptedPath, $relPath)) {
|
||||||
);
|
|
||||||
|
|
||||||
// If the file uses old
|
$found['legacy'][] = array(
|
||||||
// encryption system
|
'name' => $file,
|
||||||
} elseif (Crypt::isLegacyEncryptedContent($isEncryptedPath, $relPath)) {
|
'path' => $filePath
|
||||||
|
);
|
||||||
|
|
||||||
$found['legacy'][] = array(
|
// If the file is not encrypted
|
||||||
'name' => $file,
|
} else {
|
||||||
'path' => $filePath
|
|
||||||
);
|
|
||||||
|
|
||||||
// If the file is not encrypted
|
$found['plain'][] = array(
|
||||||
} else {
|
'name' => $file,
|
||||||
|
'path' => $relPath
|
||||||
|
);
|
||||||
|
|
||||||
$found['plain'][] = array(
|
}
|
||||||
'name' => $file,
|
|
||||||
'path' => $relPath
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
\OC_FileProxy::$enabled = true;
|
\OC_FileProxy::$enabled = true;
|
||||||
|
|
|
@ -378,7 +378,7 @@ class OC_Mount_Config {
|
||||||
}
|
}
|
||||||
$result = array();
|
$result = array();
|
||||||
$handle = opendir($path);
|
$handle = opendir($path);
|
||||||
if ( ! $handle) {
|
if(!is_resource($handle)) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
while (false !== ($file = readdir($handle))) {
|
while (false !== ($file = readdir($handle))) {
|
||||||
|
|
|
@ -221,7 +221,8 @@ class Shared extends \OC\Files\Storage\Common {
|
||||||
public function filemtime($path) {
|
public function filemtime($path) {
|
||||||
if ($path == '' || $path == '/') {
|
if ($path == '' || $path == '/') {
|
||||||
$mtime = 0;
|
$mtime = 0;
|
||||||
if ($dh = $this->opendir($path)) {
|
$dh = $this->opendir($path);
|
||||||
|
if(is_resource($dh)) {
|
||||||
while (($filename = readdir($dh)) !== false) {
|
while (($filename = readdir($dh)) !== false) {
|
||||||
$tempmtime = $this->filemtime($filename);
|
$tempmtime = $this->filemtime($filename);
|
||||||
if ($tempmtime > $mtime) {
|
if ($tempmtime > $mtime) {
|
||||||
|
|
|
@ -65,16 +65,18 @@ class MappedLocal extends \OC\Files\Storage\Common{
|
||||||
|
|
||||||
$logicalPath = $this->mapper->physicalToLogic($physicalPath);
|
$logicalPath = $this->mapper->physicalToLogic($physicalPath);
|
||||||
$dh = opendir($physicalPath);
|
$dh = opendir($physicalPath);
|
||||||
while (($file = readdir($dh)) !== false) {
|
if(is_resource($dh)) {
|
||||||
if ($file === '.' or $file === '..') {
|
while (($file = readdir($dh)) !== false) {
|
||||||
continue;
|
if ($file === '.' or $file === '..') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$logicalFilePath = $this->mapper->physicalToLogic($physicalPath.'/'.$file);
|
||||||
|
|
||||||
|
$file= $this->mapper->stripRootFolder($logicalFilePath, $logicalPath);
|
||||||
|
$file = $this->stripLeading($file);
|
||||||
|
$files[]= $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
$logicalFilePath = $this->mapper->physicalToLogic($physicalPath.'/'.$file);
|
|
||||||
|
|
||||||
$file= $this->mapper->stripRootFolder($logicalFilePath, $logicalPath);
|
|
||||||
$file = $this->stripLeading($file);
|
|
||||||
$files[]= $file;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
\OC\Files\Stream\Dir::register('local-win32'.$path, $files);
|
\OC\Files\Stream\Dir::register('local-win32'.$path, $files);
|
||||||
|
|
|
@ -341,17 +341,19 @@ class OC_Helper {
|
||||||
if (!is_dir($path))
|
if (!is_dir($path))
|
||||||
return chmod($path, $filemode);
|
return chmod($path, $filemode);
|
||||||
$dh = opendir($path);
|
$dh = opendir($path);
|
||||||
while (($file = readdir($dh)) !== false) {
|
if(is_resource($dh)) {
|
||||||
if ($file != '.' && $file != '..') {
|
while (($file = readdir($dh)) !== false) {
|
||||||
$fullpath = $path . '/' . $file;
|
if ($file != '.' && $file != '..') {
|
||||||
if (is_link($fullpath))
|
$fullpath = $path . '/' . $file;
|
||||||
return false;
|
if (is_link($fullpath))
|
||||||
elseif (!is_dir($fullpath) && !@chmod($fullpath, $filemode))
|
return false;
|
||||||
return false; elseif (!self::chmodr($fullpath, $filemode))
|
elseif (!is_dir($fullpath) && !@chmod($fullpath, $filemode))
|
||||||
return false;
|
return false; elseif (!self::chmodr($fullpath, $filemode))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
closedir($dh);
|
||||||
}
|
}
|
||||||
closedir($dh);
|
|
||||||
if (@chmod($path, $filemode))
|
if (@chmod($path, $filemode))
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
|
@ -649,9 +651,11 @@ class OC_Helper {
|
||||||
// if oc-noclean is empty delete it
|
// if oc-noclean is empty delete it
|
||||||
$isTmpDirNoCleanEmpty = true;
|
$isTmpDirNoCleanEmpty = true;
|
||||||
$tmpDirNoClean = opendir($tmpDirNoCleanName);
|
$tmpDirNoClean = opendir($tmpDirNoCleanName);
|
||||||
while (false !== ($file = readdir($tmpDirNoClean))) {
|
if(is_resource($tmpDirNoClean)) {
|
||||||
if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
|
while (false !== ($file = readdir($tmpDirNoClean))) {
|
||||||
$isTmpDirNoCleanEmpty = false;
|
if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
|
||||||
|
$isTmpDirNoCleanEmpty = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($isTmpDirNoCleanEmpty) {
|
if ($isTmpDirNoCleanEmpty) {
|
||||||
|
|
|
@ -191,7 +191,8 @@ class OC_Migration_Content{
|
||||||
if( !file_exists( $dir ) ) {
|
if( !file_exists( $dir ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($dirhandle = opendir($dir)) {
|
$dirhandle = opendir($dir);
|
||||||
|
if(is_resource($dirhandle)) {
|
||||||
while (false !== ( $file = readdir($dirhandle))) {
|
while (false !== ( $file = readdir($dirhandle))) {
|
||||||
|
|
||||||
if (( $file != '.' ) && ( $file != '..' )) {
|
if (( $file != '.' ) && ( $file != '..' )) {
|
||||||
|
|
Loading…
Reference in New Issue