diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-10-15 19:57:24 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-10-15 19:57:24 +0200 |
commit | 08cc60acbae3d8ca2372fa7198a4a1d0c197cd74 (patch) | |
tree | 1e69f3a12684452907c142f999fffa4dad7b5c4c | |
parent | f50f78dd9b57eb1ed631165f1e0d6ae1ee2d47c6 (diff) | |
parent | dd6cb67030a260c94ec00770c966bc66dc24a308 (diff) | |
download | nextcloud-server-08cc60acbae3d8ca2372fa7198a4a1d0c197cd74.tar.gz nextcloud-server-08cc60acbae3d8ca2372fa7198a4a1d0c197cd74.zip |
Merge pull request #19806 from owncloud/fix_19572
only wrap source if fopen was successful
-rw-r--r-- | lib/private/files/storage/wrapper/encryption.php | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/private/files/storage/wrapper/encryption.php b/lib/private/files/storage/wrapper/encryption.php index d6b7f53408f..2f0c1e35b04 100644 --- a/lib/private/files/storage/wrapper/encryption.php +++ b/lib/private/files/storage/wrapper/encryption.php @@ -195,9 +195,13 @@ class Encryption extends Wrapper { public function file_put_contents($path, $data) { // file put content will always be translated to a stream write $handle = $this->fopen($path, 'w'); - $written = fwrite($handle, $data); - fclose($handle); - return $written; + if (is_resource($handle)) { + $written = fwrite($handle, $data); + fclose($handle); + return $written; + } + + return false; } /** @@ -320,7 +324,7 @@ class Encryption extends Wrapper { * * @param string $path * @param string $mode - * @return resource + * @return resource|bool * @throws GenericEncryptionException * @throws ModuleDoesNotExistsException */ @@ -404,6 +408,9 @@ class Encryption extends Wrapper { if ($shouldEncrypt === true && $encryptionModule !== null) { $headerSize = $this->getHeaderSize($path); $source = $this->storage->fopen($path, $mode); + if (!is_resource($source)) { + return false; + } $handle = \OC\Files\Stream\Encryption::wrap($source, $path, $fullPath, $header, $this->uid, $encryptionModule, $this->storage, $this, $this->util, $this->fileHelper, $mode, $size, $unencryptedSize, $headerSize); |