Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <[email protected]>
  • Loading branch information
PVince81 committed Dec 9, 2021
commit 6f81e60bce600185f2bb37b36187b8751aa28344
8 changes: 6 additions & 2 deletions lib/private/Files/Storage/Wrapper/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -784,8 +784,12 @@ private function copyBetweenStorage(Storage\IStorage $sourceStorage, $sourceInte
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) {
Expand Down