diff options
author | Jörn Friedrich Dreyer <jfd@butonic.de> | 2013-02-10 17:09:31 +0100 |
---|---|---|
committer | Jörn Friedrich Dreyer <jfd@butonic.de> | 2013-02-11 09:53:07 +0100 |
commit | 15ab2fd52aa3d2971682406a0add82ba453f82f6 (patch) | |
tree | e545a325ce8dd885ddda3db566d7d4877c900996 /lib | |
parent | 806522d0073cecb2c72ec41f7ae5009024fb7512 (diff) | |
download | nextcloud-server-15ab2fd52aa3d2971682406a0add82ba453f82f6.tar.gz nextcloud-server-15ab2fd52aa3d2971682406a0add82ba453f82f6.zip |
check Content-Length to detect aborted uploads
Diffstat (limited to 'lib')
-rw-r--r-- | lib/connector/sabre/directory.php | 10 | ||||
-rw-r--r-- | lib/connector/sabre/file.php | 9 |
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php index 6465dcbac30..a5676d656ec 100644 --- a/lib/connector/sabre/directory.php +++ b/lib/connector/sabre/directory.php @@ -68,6 +68,16 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa \OC\Files\Filesystem::file_put_contents($partpath, $data); + //detect aborted upload + if (isset($_SERVER['CONTENT_LENGTH']) + && \OC\Files\Filesystem::filesize($partpath) != $_SERVER['CONTENT_LENGTH']) + { + throw new Sabre_DAV_Exception_BadRequest( + 'expected filesize ' . $_SERVER['CONTENT_LENGTH']. + ' got ' . \OC\Files\Filesystem::filesize($partpath) + ); + } + // rename to correct path \OC\Files\Filesystem::rename($partpath, $newPath); diff --git a/lib/connector/sabre/file.php b/lib/connector/sabre/file.php index 279615b9237..ab342fa2c64 100644 --- a/lib/connector/sabre/file.php +++ b/lib/connector/sabre/file.php @@ -50,6 +50,15 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D \OC\Files\Filesystem::file_put_contents($partpath, $data); + //detect aborted upload + if (isset($_SERVER['CONTENT_LENGTH']) + && \OC\Files\Filesystem::filesize($partpath) != $_SERVER['CONTENT_LENGTH']) + { + throw new Sabre_DAV_Exception_BadRequest( + 'expected filesize ' . $_SERVER['CONTENT_LENGTH']. + ' got ' . \OC\Files\Filesystem::filesize($partpath) + ); + } // rename to correct path \OC\Files\Filesystem::rename($partpath, $this->path); |