Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2021-06-07 22:37:02 +0300
committerGitHub <noreply@github.com>2021-06-07 22:37:02 +0300
commit9f62c8023de1425887b8a21283c265ff91c0ceea (patch)
tree36308f3f366e1768662e16675801bdaa6822a09f /lib
parentac5d4a8bfc59893aded2ea164abd7b9a7b0da714 (diff)
parentb486855783c38cd857f233485187a7a31ba0fe47 (diff)
Merge pull request #27349 from nextcloud/backport/25280/stable20
[stable20] Set umask before operations that create local files
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Avatar/Avatar.php5
-rw-r--r--lib/private/Files/Storage/Local.php23
2 files changed, 22 insertions, 6 deletions
diff --git a/lib/private/Avatar/Avatar.php b/lib/private/Avatar/Avatar.php
index 02fc04eae36..a7395362ff6 100644
--- a/lib/private/Avatar/Avatar.php
+++ b/lib/private/Avatar/Avatar.php
@@ -156,8 +156,9 @@ abstract class Avatar implements IAvatar {
$avatar->readImageBlob($svg);
$avatar->setImageFormat('png');
$image = new OC_Image();
- $image->loadFromData($avatar);
- return $image->data();
+ $image->loadFromData((string)$avatar);
+ $data = $image->data();
+ return $data === null ? false : $data;
} catch (\Exception $e) {
return false;
}
diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php
index 26687f96081..0ef58698623 100644
--- a/lib/private/Files/Storage/Local.php
+++ b/lib/private/Files/Storage/Local.php
@@ -87,7 +87,11 @@ class Local extends \OC\Files\Storage\Common {
}
public function mkdir($path) {
- return @mkdir($this->getSourcePath($path), 0777, true);
+ $sourcePath = $this->getSourcePath($path);
+ $oldMask = umask(022);
+ $result = @mkdir($sourcePath, 0777, true);
+ umask($oldMask);
+ return $result;
}
public function rmdir($path) {
@@ -256,11 +260,13 @@ class Local extends \OC\Files\Storage\Common {
if ($this->file_exists($path) and !$this->isUpdatable($path)) {
return false;
}
+ $oldMask = umask(022);
if (!is_null($mtime)) {
$result = @touch($this->getSourcePath($path), $mtime);
} else {
$result = @touch($this->getSourcePath($path));
}
+ umask($oldMask);
if ($result) {
clearstatcache(true, $this->getSourcePath($path));
}
@@ -273,7 +279,10 @@ class Local extends \OC\Files\Storage\Common {
}
public function file_put_contents($path, $data) {
- return file_put_contents($this->getSourcePath($path), $data);
+ $oldMask = umask(022);
+ $result = file_put_contents($this->getSourcePath($path), $data);
+ umask($oldMask);
+ return $result;
}
public function unlink($path) {
@@ -343,12 +352,18 @@ class Local extends \OC\Files\Storage\Common {
if ($this->is_dir($path1)) {
return parent::copy($path1, $path2);
} else {
- return copy($this->getSourcePath($path1), $this->getSourcePath($path2));
+ $oldMask = umask(022);
+ $result = copy($this->getSourcePath($path1), $this->getSourcePath($path2));
+ umask($oldMask);
+ return $result;
}
}
public function fopen($path, $mode) {
- return fopen($this->getSourcePath($path), $mode);
+ $oldMask = umask(022);
+ $result = fopen($this->getSourcePath($path), $mode);
+ umask($oldMask);
+ return $result;
}
public function hash($type, $path, $raw = false) {