Skip to content

Commit 823e91d

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 317f1d3 commit 823e91d

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
@@ -748,6 +748,18 @@ private function copyFile(ICache $sourceCache, ICacheEntry $sourceEntry, string
748748

749749
$targetId = $cache->copyFromCache($sourceCache, $sourceEntry, $to);
750750

751+
if ($targetId === $sourceEntry->getId()) {
752+
// copying a file to itself? No need to do anything
753+
$e = new \Exception('Object ' . $sourceEntry->getPath() . ' (' . $sourceEntry->getId() . ') being copied to itself');
754+
if ($sourceEntry instanceof CacheEntry) {
755+
$sourceData = $sourceEntry->getData();
756+
} else {
757+
$sourceData = null;
758+
}
759+
$this->logger->warning($e->getMessage(), ['exception' => $e, 'source' => $sourceData]);
760+
return;
761+
}
762+
751763
$targetUrn = $this->getURN($targetId);
752764

753765
try {

0 commit comments

Comments
 (0)