Skip to content

Commit ecfb76f

Browse files
committed
fix: add some extra checks for getMountsForPath arguments
Signed-off-by: Robin Appelman <[email protected]>
1 parent 396e7dd commit ecfb76f

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

lib/private/Files/Config/MountProviderCollection.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,12 @@ public function getMountsForUser(IUser $user): array {
8484
}
8585

8686
/**
87-
* @param MountProviderArgs[] $mountProviderArgs
88-
* @return array<string, IMountPoint> IMountPoint array indexed by mount
89-
* point.
87+
* The caller is responsible to ensure that all provided MountProviderArgs
88+
* are for the same user.
89+
* And that the `$providerClass` implements IPartialMountProvider.
90+
*
91+
* @param list<MountProviderArgs> $mountProviderArgs
92+
* @return array<string, IMountPoint> IMountPoint array indexed by mount point.
9093
*/
9194
public function getUserMountsFromProviderByPath(
9295
string $providerClass,
@@ -98,14 +101,16 @@ public function getUserMountsFromProviderByPath(
98101
if ($provider === null) {
99102
return [];
100103
}
104+
if (count($mountProviderArgs) === 0) {
105+
return [];
106+
}
101107

102-
if (!is_a($providerClass, IPartialMountProvider::class, true)) {
108+
if (!$provider instanceof IPartialMountProvider) {
103109
throw new \LogicException(
104110
'Mount provider does not support partial mounts'
105111
);
106112
}
107113

108-
/** @var IPartialMountProvider $provider */
109114
return $provider->getMountsForPath(
110115
$path,
111116
$forChildren,

lib/private/Files/SetupManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ public function setupForPath(string $path, bool $includeChildren = false): void
600600
}
601601
$this->setupMountProviderPaths[$mountPoint] = self::SETUP_WITH_CHILDREN;
602602
foreach ($authoritativeCachedMounts as $providerClass => $cachedMounts) {
603-
$providerArgs = array_filter(array_map(
603+
$providerArgs = array_values(array_filter(array_map(
604604
static function (ICachedMountInfo $info) use ($rootsMetadata) {
605605
$rootMetadata = $rootsMetadata[$info->getRootId()] ?? null;
606606

@@ -609,7 +609,7 @@ static function (ICachedMountInfo $info) use ($rootsMetadata) {
609609
: null;
610610
},
611611
$cachedMounts
612-
));
612+
)));
613613
$authoritativeMounts[] = $this->mountProviderCollection->getUserMountsFromProviderByPath(
614614
$providerClass,
615615
$path,

0 commit comments

Comments
 (0)