summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2021-12-09 11:28:10 +0100
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2021-12-10 00:10:44 +0000
commit65d4d30251d86e17a745ddc73344da7c8c63eb4a (patch)
tree32ab0b3ac0eeb158fed2aaa349755a6804188afd /lib
parent80ff47e829afab47788155a3c6e4c5f47e3dcc21 (diff)
downloadnextcloud-server-65d4d30251d86e17a745ddc73344da7c8c63eb4a.tar.gz
nextcloud-server-65d4d30251d86e17a745ddc73344da7c8c63eb4a.zip
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')
-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 ef5697cdd24..7aa092ba61f 100644
--- a/lib/private/Files/Storage/Wrapper/Encryption.php
+++ b/lib/private/Files/Storage/Wrapper/Encryption.php
@@ -756,8 +756,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) {