Skip to content

Commit a2d0f5d

Browse files
icewind1991backportbot[bot]
authored andcommitted
fix: harden object store against copying a file to itself
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 2cade7c commit a2d0f5d

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

lib/private/Files/ObjectStore/ObjectStoreStorage.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,18 @@ private function copyFile(ICache $sourceCache, ICacheEntry $sourceEntry, string
723723

724724
$targetId = $cache->copyFromCache($sourceCache, $sourceEntry, $to);
725725

726+
if ($targetId === $sourceEntry->getId()) {
727+
// copying a file to itself? No need to do anything
728+
$e = new \Exception('Object ' . $sourceEntry->getPath() . ' (' . $sourceEntry->getId() . ') being copied to itself');
729+
if ($sourceEntry instanceof CacheEntry) {
730+
$sourceData = $sourceEntry->getData();
731+
} else {
732+
$sourceData = null;
733+
}
734+
$this->logger->warning($e->getMessage(), ['exception' => $e, 'source' => $sourceData]);
735+
return;
736+
}
737+
726738
$targetUrn = $this->getURN($targetId);
727739

728740
try {

0 commit comments

Comments
 (0)