From cf9dbc6e349bc287a414547944fd2a6dff383d64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Tue, 24 Sep 2013 14:25:56 +0200 Subject: [PATCH] adding error handling on file_put_contents within the web dav implementation --- lib/connector/sabre/directory.php | 7 ++++++- lib/connector/sabre/file.php | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php index 3181a4b310..0717d95226 100644 --- a/lib/connector/sabre/directory.php +++ b/lib/connector/sabre/directory.php @@ -72,7 +72,12 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa // mark file as partial while uploading (ignored by the scanner) $partpath = $newPath . '.part'; - \OC\Files\Filesystem::file_put_contents($partpath, $data); + $putOkay = \OC\Files\Filesystem::file_put_contents($partpath, $data); + if ($putOkay === false) { + \OC_Log::write('webdav', '\OC\Files\Filesystem::file_put_contents() failed', \OC_Log::ERROR); + \OC\Files\Filesystem::unlink($partpath); + throw new Sabre_DAV_Exception(); + } //detect aborted upload if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT' ) { diff --git a/lib/connector/sabre/file.php b/lib/connector/sabre/file.php index 61bdcd5e0a..57ba94c7b1 100644 --- a/lib/connector/sabre/file.php +++ b/lib/connector/sabre/file.php @@ -58,7 +58,12 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D // mark file as partial while uploading (ignored by the scanner) $partpath = $this->path . '.part'; - \OC\Files\Filesystem::file_put_contents($partpath, $data); + $putOkay = \OC\Files\Filesystem::file_put_contents($partpath, $data); + if ($putOkay === false) { + \OC_Log::write('webdav', '\OC\Files\Filesystem::file_put_contents() failed', \OC_Log::ERROR); + \OC\Files\Filesystem::unlink($partpath); + throw new Sabre_DAV_Exception(); + } //detect aborted upload if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT') {