From afa85490c94ff6ab473d5cba67e53752317f5c7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Mon, 25 Aug 2025 11:51:58 +0200 Subject: [PATCH 1/2] fix(encryption): Fix TypeError when trying to decrypt unencrypted file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- lib/private/Files/Storage/Wrapper/Encryption.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php index 7cbfa8a126aa8..78a96c572962c 100644 --- a/lib/private/Files/Storage/Wrapper/Encryption.php +++ b/lib/private/Files/Storage/Wrapper/Encryption.php @@ -813,6 +813,8 @@ private function copyBetweenStorage( } } } else { + $source = false; + $target = false; try { $source = $sourceStorage->fopen($sourceInternalPath, 'r'); $target = $this->fopen($targetInternalPath, 'w'); @@ -822,10 +824,10 @@ private function copyBetweenStorage( [, $result] = \OC_Helper::streamCopy($source, $target); } } finally { - if (isset($source) && $source !== false) { + if ($source !== false) { fclose($source); } - if (isset($target) && $target !== false) { + if ($target !== false) { fclose($target); } } From 75f9eda0874e46c926cea3a81d53a158b34951a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Mon, 25 Aug 2025 12:38:41 +0200 Subject: [PATCH 2/2] fix(tests): Fix fopen in mock returning null which is not a valid return MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- tests/lib/Files/ViewTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index edda380b549ee..bec27b228ed75 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -1183,6 +1183,9 @@ private function doTestCopyRenameFail($operation) { $storage2->method('writeStream') ->willThrowException(new GenericFileException('Failed to copy stream')); + $storage2->method('fopen') + ->willReturn(false); + $storage1->mkdir('sub'); $storage1->file_put_contents('foo.txt', '0123456789ABCDEFGH'); $storage1->mkdir('dirtomove');