From 2cade7cdd13b039e5a281b4d15ede48ccae84130 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 8ab1622eb9e62..5ecf77b3a8406 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -708,11 +708,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()); @@ -721,7 +721,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 a2d0f5da4dea84a8af7bca8b253a39c7b5342f1d 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 5ecf77b3a8406..df1bbad69dbb8 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -723,6 +723,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 {