Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2021-12-09 13:28:10 +0300
committerVincent Petry <vincent@nextcloud.com>2021-12-09 13:28:10 +0300
commit6f81e60bce600185f2bb37b36187b8751aa28344 (patch)
treeea12dc8282b4ddaee27fe44858442688fb68b0fc /lib/private/Files/Storage
parent3a1ef2b012a903ee4e08483fd47afbd6fc111ca3 (diff)
Check resource before closing in encryption wrapper
In case of error there is no guarantee that $source or $target is set or is a resource when handling an error. Without this fix, there's a risk that fclose will fail and the actual exception will not be thrown, making it impossible to find out about the root cause. Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Diffstat (limited to 'lib/private/Files/Storage')
-rw-r--r--lib/private/Files/Storage/Wrapper/Encryption.php8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php
index 308952c2a31..3ee715ae3d3 100644
--- a/lib/private/Files/Storage/Wrapper/Encryption.php
+++ b/lib/private/Files/Storage/Wrapper/Encryption.php
@@ -784,8 +784,12 @@ class Encryption extends Wrapper {
fclose($source);
fclose($target);
} catch (\Exception $e) {
- fclose($source);
- fclose($target);
+ if (is_resource($source)) {
+ fclose($source);
+ }
+ if (is_resource($target)) {
+ fclose($target);
+ }
throw $e;
}
if ($result) {