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:
authorblizzz <blizzz@arthur-schiwon.de>2021-09-23 11:05:05 +0300
committerGitHub <noreply@github.com>2021-09-23 11:05:05 +0300
commit8687bec176cf4a783e6e7c26ce93b741bced0a40 (patch)
tree1bef00486781494cc9f6791a34a877a913df6f31 /lib
parent7a34dd4a97a65943c6292d5d0c88efcb9e996bab (diff)
parent8466c53e0055558a7719de382ae148424f018513 (diff)
Merge pull request #27407 from nextcloud/backport/24966/stable20
[stable20] avoid fread on directories and unencrypted files
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/Storage/Wrapper/Encryption.php25
1 files changed, 12 insertions, 13 deletions
diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php
index d6143dccfb3..22201c9db83 100644
--- a/lib/private/Files/Storage/Wrapper/Encryption.php
+++ b/lib/private/Files/Storage/Wrapper/Encryption.php
@@ -923,21 +923,20 @@ class Encryption extends Wrapper {
$path = $realFile;
}
- $firstBlock = $this->readFirstBlock($path);
- $result = $this->parseRawHeader($firstBlock);
+ $result = [];
+
+ // first check if it is an encrypted file at all
+ // We would do query to filecache only if we know that entry in filecache exists
+
+ $info = $this->getCache()->get($path);
+ if (isset($info['encrypted']) && $info['encrypted'] === true) {
+ $firstBlock = $this->readFirstBlock($path);
+ $result = $this->parseRawHeader($firstBlock);
- // if the header doesn't contain a encryption module we check if it is a
- // legacy file. If true, we add the default encryption module
- if (!isset($result[Util::HEADER_ENCRYPTION_MODULE_KEY])) {
- if (!empty($result)) {
+ // if the header doesn't contain a encryption module we check if it is a
+ // legacy file. If true, we add the default encryption module
+ if (!isset($result[Util::HEADER_ENCRYPTION_MODULE_KEY]) && (!empty($result) || $exists)) {
$result[Util::HEADER_ENCRYPTION_MODULE_KEY] = 'OC_DEFAULT_MODULE';
- } elseif ($exists) {
- // if the header was empty we have to check first if it is a encrypted file at all
- // We would do query to filecache only if we know that entry in filecache exists
- $info = $this->getCache()->get($path);
- if (isset($info['encrypted']) && $info['encrypted'] === true) {
- $result[Util::HEADER_ENCRYPTION_MODULE_KEY] = 'OC_DEFAULT_MODULE';
- }
}
}