summaryrefslogtreecommitdiffstats
path: root/apps/dav/lib
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2017-02-24 11:56:29 +0100
committerJoas Schilling <coding@schilljs.com>2017-04-27 09:29:02 +0200
commit614bd5c29419c9f45d4fa826539c544a6d7c2e26 (patch)
tree2d2d0cecc5cd788ee44775c893280567ef658d22 /apps/dav/lib
parent53deb26778c674760acd0bc3ca08e8fbc607a034 (diff)
downloadnextcloud-server-614bd5c29419c9f45d4fa826539c544a6d7c2e26.tar.gz
nextcloud-server-614bd5c29419c9f45d4fa826539c544a6d7c2e26.zip
Properly handle missing READ permission
Diffstat (limited to 'apps/dav/lib')
-rw-r--r--apps/dav/lib/Connector/Sabre/Directory.php11
-rw-r--r--apps/dav/lib/Connector/Sabre/File.php5
-rw-r--r--apps/dav/lib/Connector/Sabre/FilesPlugin.php4
3 files changed, 20 insertions, 0 deletions
diff --git a/apps/dav/lib/Connector/Sabre/Directory.php b/apps/dav/lib/Connector/Sabre/Directory.php
index 9afa6367685..579dbbabf44 100644
--- a/apps/dav/lib/Connector/Sabre/Directory.php
+++ b/apps/dav/lib/Connector/Sabre/Directory.php
@@ -44,6 +44,7 @@ use Sabre\DAV\INode;
use Sabre\DAV\Exception\BadRequest;
use OC\Files\Mount\MoveableMount;
use Sabre\DAV\IFile;
+use Sabre\DAV\Exception\NotFound;
class Directory extends \OCA\DAV\Connector\Sabre\Node
implements \Sabre\DAV\ICollection, \Sabre\DAV\IQuota, \Sabre\DAV\IMoveTarget {
@@ -199,6 +200,11 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node
* @throws \Sabre\DAV\Exception\ServiceUnavailable
*/
public function getChild($name, $info = null) {
+ if (!$this->info->isReadable()) {
+ // avoid detecting files through this way
+ throw new NotFound();
+ }
+
$path = $this->path . '/' . $name;
if (is_null($info)) {
try {
@@ -232,12 +238,17 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node
* Returns an array with all the child nodes
*
* @return \Sabre\DAV\INode[]
+ * @throws \Sabre\DAV\Exception\Locked
+ * @throws \OCA\DAV\Connector\Sabre\Exception\Forbidden
*/
public function getChildren() {
if (!is_null($this->dirContent)) {
return $this->dirContent;
}
try {
+ if (!$this->info->isReadable()) {
+ throw new Forbidden('No read permissions');
+ }
$folderContent = $this->fileView->getDirectoryContent($this->path);
} catch (LockedException $e) {
throw new Locked();
diff --git a/apps/dav/lib/Connector/Sabre/File.php b/apps/dav/lib/Connector/Sabre/File.php
index 1f878df1564..7a8bdb1da75 100644
--- a/apps/dav/lib/Connector/Sabre/File.php
+++ b/apps/dav/lib/Connector/Sabre/File.php
@@ -54,6 +54,7 @@ use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\Exception\NotImplemented;
use Sabre\DAV\Exception\ServiceUnavailable;
use Sabre\DAV\IFile;
+use Sabre\DAV\Exception\NotFound;
class File extends Node implements IFile {
@@ -307,6 +308,10 @@ class File extends Node implements IFile {
public function get() {
//throw exception if encryption is disabled but files are still encrypted
try {
+ if (!$this->info->isReadable()) {
+ // do a if the file did not exist
+ throw new NotFound();
+ }
$res = $this->fileView->fopen(ltrim($this->path, '/'), 'rb');
if ($res === false) {
throw new ServiceUnavailable("Could not open file");
diff --git a/apps/dav/lib/Connector/Sabre/FilesPlugin.php b/apps/dav/lib/Connector/Sabre/FilesPlugin.php
index 929cd1b0bea..a4f3f363a5f 100644
--- a/apps/dav/lib/Connector/Sabre/FilesPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/FilesPlugin.php
@@ -286,6 +286,10 @@ class FilesPlugin extends ServerPlugin {
$httpRequest = $this->server->httpRequest;
if ($node instanceof \OCA\DAV\Connector\Sabre\Node) {
+ if (!$node->getFileInfo()->isReadable()) {
+ // avoid detecting files through this means
+ throw new NotFound();
+ }
$propFind->handle(self::FILEID_PROPERTYNAME, function() use ($node) {
return $node->getFileId();