From 7017de49b33b8dc5a6e25f11598256f04b7846a9 Mon Sep 17 00:00:00 2001 From: HarryKipper Date: Fri, 26 Apr 2024 09:50:06 +0100 Subject: [PATCH] Add checks to SFTP.php Fixes https://github.com/owncloud/core/issues/41159 --- apps/files_external/lib/Lib/Storage/SFTP.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/files_external/lib/Lib/Storage/SFTP.php b/apps/files_external/lib/Lib/Storage/SFTP.php index eb789f6ca87c..a39dd151b2ee 100644 --- a/apps/files_external/lib/Lib/Storage/SFTP.php +++ b/apps/files_external/lib/Lib/Storage/SFTP.php @@ -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) {