[Pkg-owncloud-commits] [owncloud] 103/457: encrypted filesize calculation in flush()
David Prévot
taffit at moszumanska.debian.org
Sun Jun 28 20:05:38 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch stable8
in repository owncloud.
commit fb51880a4a5a2afb79b7aa1e9c041c300cf34e9c
Author: jknockaert <jasper at knockaert.nl>
Date: Wed May 20 09:35:20 2015 +0200
encrypted filesize calculation in flush()
---
lib/private/files/stream/encryption.php | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lib/private/files/stream/encryption.php b/lib/private/files/stream/encryption.php
index f2f5b9c..7c8e6d4 100644
--- a/lib/private/files/stream/encryption.php
+++ b/lib/private/files/stream/encryption.php
@@ -412,7 +412,14 @@ class Encryption extends Wrapper {
$encrypted = $this->encryptionModule->encrypt($this->cache);
parent::stream_write($encrypted);
$this->writeFlag = false;
- $this->size = max($this->size, parent::stream_tell());
+ // If the write concerns the last block then then update the encrypted filesize
+ // Note that the unencrypted pointer and filesize are NOT yet updated when flush() is called
+ // We recalculate the encrypted filesize as we do not know the context of calling flush()
+ if ((int)floor($this->unencryptedSize/$this->unencryptedBlockSize) === (int)floor($this->position/$this->unencryptedBlockSize)) {
+ $this->size = $this->util->getBlockSize() * (int)floor($this->unencryptedSize/$this->unencryptedBlockSize);
+ $this->size += strlen($encrypted);
+ $this->size += $this->headerSize;
+ }
}
// always empty the cache (otherwise readCache() will not fill it with the new block)
$this->cache = '';
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list