From deecb48e54c50ebb8cac092be1f1fc111d9941c6 Mon Sep 17 00:00:00 2001 From: Josh Richards Date: Thu, 3 Aug 2023 09:53:46 -0400 Subject: [PATCH 1/2] Catch more invalid cache source storage paths OC\Files\Cache\Cache::get can return string|false|null, not just string|false. - nextcloud/server#26270 added handling of false, but null is needed too. - Well, or we change the default $resullt to false, but I'm not sure if that has other ramifications and the real need here is to simply catch situations where the cache source storage path is not valid for whatever reason Related: nextcloud/server#19009 Signed-off-by: Josh Richards --- lib/private/Files/Cache/Cache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index 4770e168bfbec..d3593cac8b9bf 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -668,7 +668,7 @@ public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { $targetPath = $this->normalize($targetPath); $sourceData = $sourceCache->get($sourcePath); - if ($sourceData === false) { + if ($sourceData === false || $sourceData === null) { throw new \Exception('Invalid source storage path: ' . $sourcePath); } From 7b7d1e3c0911639cba4c20eba7d0a8352091643f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6?= Date: Sat, 5 Aug 2023 12:05:36 +0200 Subject: [PATCH 2/2] fix: simplify `sourceData` check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Git'Fellow <12234510+solracsf@users.noreply.github.com> Signed-off-by: John Molakvoæ --- lib/private/Files/Cache/Cache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index d3593cac8b9bf..287966e4a284d 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -668,7 +668,7 @@ public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { $targetPath = $this->normalize($targetPath); $sourceData = $sourceCache->get($sourcePath); - if ($sourceData === false || $sourceData === null) { + if (!$sourceData) { throw new \Exception('Invalid source storage path: ' . $sourcePath); }