From 317f1d3b6982c537c998fb0385aa10f3125eb6e3 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 4 Jun 2026 00:36:02 +0200 Subject: [PATCH 1/2] fix: pass correct source cache in ObjectStoreStorage::copyFile I don't think this actually matters, but better to be correct Signed-off-by: Robin Appelman --- lib/private/Files/ObjectStore/ObjectStoreStorage.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index 80cd79bb0a92b..2336ed9f85960 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -733,11 +733,11 @@ private function copyInner(ICache $sourceCache, ICacheEntry $sourceEntry, string $this->copyInner($sourceCache, $child, $to . '/' . $child->getName()); } } else { - $this->copyFile($sourceEntry, $to); + $this->copyFile($sourceCache, $sourceEntry, $to); } } - private function copyFile(ICacheEntry $sourceEntry, string $to) { + private function copyFile(ICache $sourceCache, ICacheEntry $sourceEntry, string $to) { $cache = $this->getCache(); $sourceUrn = $this->getURN($sourceEntry->getId()); @@ -746,7 +746,7 @@ private function copyFile(ICacheEntry $sourceEntry, string $to) { throw new \Exception('Invalid source cache for object store copy'); } - $targetId = $cache->copyFromCache($cache, $sourceEntry, $to); + $targetId = $cache->copyFromCache($sourceCache, $sourceEntry, $to); $targetUrn = $this->getURN($targetId); From 823e91d064add5690e254a8001b46367efbabcc1 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 4 Jun 2026 00:42:16 +0200 Subject: [PATCH 2/2] fix: harden object store against copying a file to itself Signed-off-by: Robin Appelman --- lib/private/Files/ObjectStore/ObjectStoreStorage.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index 2336ed9f85960..1704df6cca015 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -748,6 +748,18 @@ private function copyFile(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetId = $cache->copyFromCache($sourceCache, $sourceEntry, $to); + if ($targetId === $sourceEntry->getId()) { + // copying a file to itself? No need to do anything + $e = new \Exception('Object ' . $sourceEntry->getPath() . ' (' . $sourceEntry->getId() . ') being copied to itself'); + if ($sourceEntry instanceof CacheEntry) { + $sourceData = $sourceEntry->getData(); + } else { + $sourceData = null; + } + $this->logger->warning($e->getMessage(), ['exception' => $e, 'source' => $sourceData]); + return; + } + $targetUrn = $this->getURN($targetId); try {