aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2025-01-28 09:31:41 +0100
committerFerdinand Thiessen <opensource@fthiessen.de>2025-01-28 09:31:41 +0100
commit701a15889ed1dc8362ced87c5a5ec9e16c3ffe3d (patch)
treecc5b48bff254b598dc80d9be690322a278dfa239
parent75fb0943d31cbd9e5679e4c2783a6b6390b985d8 (diff)
downloadnextcloud-server-701a15889ed1dc8362ced87c5a5ec9e16c3ffe3d.tar.gz
nextcloud-server-701a15889ed1dc8362ced87c5a5ec9e16c3ffe3d.zip
fixup! fixup! fix: Harden files scanner for invalid null access
-rw-r--r--apps/files_sharing/lib/External/Scanner.php5
-rw-r--r--apps/files_sharing/lib/Scanner.php2
-rw-r--r--lib/private/Files/Cache/Scanner.php2
-rw-r--r--lib/private/Files/ObjectStore/ObjectStoreScanner.php4
4 files changed, 7 insertions, 6 deletions
diff --git a/apps/files_sharing/lib/External/Scanner.php b/apps/files_sharing/lib/External/Scanner.php
index d3b54e0f0f6..e45d3723923 100644
--- a/apps/files_sharing/lib/External/Scanner.php
+++ b/apps/files_sharing/lib/External/Scanner.php
@@ -29,9 +29,10 @@ class Scanner extends \OC\Files\Cache\Scanner {
* @param string $file file to scan
* @param int $reuseExisting
* @param int $parentId
- * @param array | null $cacheData existing data in the cache for the file to be scanned
+ * @param \OC\Files\Cache\CacheEntry|array|null|false $cacheData existing data in the cache for the file to be scanned
* @param bool $lock set to false to disable getting an additional read lock during scanning
- * @return array | null an array of metadata of the scanned file
+ * @param array|null $data the metadata for the file, as returned by the storage
+ * @return array|null an array of metadata of the scanned file
*/
public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true, $data = null) {
try {
diff --git a/apps/files_sharing/lib/Scanner.php b/apps/files_sharing/lib/Scanner.php
index d346d34cb03..8a695ce9539 100644
--- a/apps/files_sharing/lib/Scanner.php
+++ b/apps/files_sharing/lib/Scanner.php
@@ -57,7 +57,7 @@ class Scanner extends \OC\Files\Cache\Scanner {
$sourceScanner = $this->getSourceScanner();
if ($sourceScanner instanceof ObjectStoreScanner) {
// ObjectStoreScanner doesn't scan
- return [];
+ return null;
} else {
return parent::scanFile($file, $reuseExisting, $parentId, $cacheData, $lock);
}
diff --git a/lib/private/Files/Cache/Scanner.php b/lib/private/Files/Cache/Scanner.php
index 33c871bfed5..1fb408a0655 100644
--- a/lib/private/Files/Cache/Scanner.php
+++ b/lib/private/Files/Cache/Scanner.php
@@ -136,7 +136,7 @@ class Scanner extends BasicEmitter implements IScanner {
}
try {
- $data = is_array($data) ? $data : $this->getData($file);
+ $data = $data ?? $this->getData($file);
} catch (ForbiddenException $e) {
if ($lock) {
if ($this->storage->instanceOfStorage(ILockingStorage::class)) {
diff --git a/lib/private/Files/ObjectStore/ObjectStoreScanner.php b/lib/private/Files/ObjectStore/ObjectStoreScanner.php
index d8a77d36dee..05929a49aab 100644
--- a/lib/private/Files/ObjectStore/ObjectStoreScanner.php
+++ b/lib/private/Files/ObjectStore/ObjectStoreScanner.php
@@ -13,11 +13,11 @@ use OCP\Files\FileInfo;
class ObjectStoreScanner extends Scanner {
public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true, $data = null) {
- return [];
+ return null;
}
public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) {
- return [];
+ return null;
}
protected function scanChildren(string $path, $recursive, int $reuse, int $folderId, bool $lock, int|float $oldSize, &$etagChanged = false) {