Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type checks to SFTP.php #41240

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions apps/files_external/lib/Lib/Storage/SFTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,18 @@ public function opendir($path) {
public function filetype($path) {
try {
$stat = $this->getConnection()->stat($this->absPath($path));
if (!is_array($stat) || !array_key_exists('type', $stat)) {
return false;
}
/* ToDo: Investigate if NET_SFTP_TYPE_REGULAR is an available constant */
/* @phan-suppress-next-line PhanUndeclaredConstant */
if ($stat['type'] == NET_SFTP_TYPE_REGULAR) {
if ((int) $stat['type'] === NET_SFTP_TYPE_REGULAR) {
return 'file';
}

/* ToDo: Investigate if NET_SFTP_TYPE_DIRECTORY is an available constant */
/* @phan-suppress-next-line PhanUndeclaredConstant */
if ($stat['type'] == NET_SFTP_TYPE_DIRECTORY) {
if ((int) $stat['type'] === NET_SFTP_TYPE_DIRECTORY) {
return 'dir';
}
} catch (\Exception $e) {
Expand Down