]> source.dussan.org Git - nextcloud-server.git/commitdiff
Don't return file handle if the mode supports writing and the file is not writable
authorMichael Gapczynski <mtgap@owncloud.com>
Wed, 8 Aug 2012 15:25:24 +0000 (11:25 -0400)
committerJörn Friedrich Dreyer <jfd@butonic.de>
Fri, 24 Aug 2012 12:58:48 +0000 (14:58 +0200)
Conflicts:
apps/files_sharing/sharedstorage.php

apps/files_sharing/sharedstorage.php

index 8b1933828386a37b48bad2b7520b9f4b7454fd2e..a2dfe34402f1c5542ef0a97c3b92f1fb40da09ec 100644 (file)
@@ -416,6 +416,25 @@ class OC_Filestorage_Shared extends OC_Filestorage {
        public function fopen($path, $mode) {
                $source = $this->getSource($path);
                if ($source) {
+                       switch ($mode) {
+                               case 'r+':
+                               case 'rb+':
+                               case 'w+':
+                               case 'wb+':
+                               case 'x+':
+                               case 'xb+':
+                               case 'a+':
+                               case 'ab+':
+                               case 'w':
+                               case 'wb':
+                               case 'x':
+                               case 'xb':
+                               case 'a':
+                               case 'ab':
+                                       if (!$this->is_writable($path)) {
+                                               return false;
+                                       }
+                       }
                        $storage = OC_Filesystem::getStorage($source);
                        return $storage->fopen($this->getInternalPath($source), $mode);
                }