aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Files
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-03-08 21:58:11 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2018-03-27 16:23:06 +0200
commit53447ae2b2066d751b2a998c3ed0a2692c72f6c4 (patch)
treecaf811dbcf1b7ea8900f2e6d8a72b65148039b5b /lib/private/Files
parent709589f2dbe3ce49f3bd71e1531e723353ee631d (diff)
downloadnextcloud-server-53447ae2b2066d751b2a998c3ed0a2692c72f6c4.tar.gz
nextcloud-server-53447ae2b2066d751b2a998c3ed0a2692c72f6c4.zip
Throw an exception if file_put_contents fails
* This will help with AppData hardening etc * Introduced a GenericFileException for if nothing else is appropiate - Maybe the other File exceptions should base on this? Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Files')
-rw-r--r--lib/private/Files/Node/File.php6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/private/Files/Node/File.php b/lib/private/Files/Node/File.php
index 4bfa5d583f7..2ddbac97dce 100644
--- a/lib/private/Files/Node/File.php
+++ b/lib/private/Files/Node/File.php
@@ -26,6 +26,7 @@
namespace OC\Files\Node;
+use OCP\Files\GenericFileException;
use OCP\Files\NotPermittedException;
class File extends Node implements \OCP\Files\File {
@@ -57,11 +58,14 @@ class File extends Node implements \OCP\Files\File {
/**
* @param string $data
* @throws \OCP\Files\NotPermittedException
+ * @throws \OCP\Files\GenericFileException
*/
public function putContent($data) {
if ($this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE)) {
$this->sendHooks(array('preWrite'));
- $this->view->file_put_contents($this->path, $data);
+ if ($this->view->file_put_contents($this->path, $data) === false) {
+ throw new GenericFileException('file_put_contents failed');
+ }
$this->fileInfo = null;
$this->sendHooks(array('postWrite'));
} else {