diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2016-02-09 20:05:07 +0100 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2016-02-09 23:43:27 +0100 |
commit | 377d7fb8a817f337552e444c5aea9eb82bcfada4 (patch) | |
tree | f9a27b18643f41925f40e63c53a9fa024c178614 /apps/encryption | |
parent | 3736f1382632716102ab2c99a1028ba7bdede5f4 (diff) | |
download | nextcloud-server-377d7fb8a817f337552e444c5aea9eb82bcfada4.tar.gz nextcloud-server-377d7fb8a817f337552e444c5aea9eb82bcfada4.zip |
don't decrease ->version for part files but only a local variable, otherwise it can happen that we decrease it twice and end up with the wrong value
Diffstat (limited to 'apps/encryption')
-rw-r--r-- | apps/encryption/lib/crypto/encryption.php | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/apps/encryption/lib/crypto/encryption.php b/apps/encryption/lib/crypto/encryption.php index 403b617c5bb..645d17f8184 100644 --- a/apps/encryption/lib/crypto/encryption.php +++ b/apps/encryption/lib/crypto/encryption.php @@ -231,11 +231,13 @@ class Encryption implements IEncryptionModule { if ($this->isWriteOperation) { // Partial files do not increase the version if(\OC\Files\Cache\Scanner::isPartialFile($path)) { - $this->version = $this->version-1; + $version = $this->version; + } else { + $version = $this->version + 1; } $this->keyManager->setVersion($this->path, $this->version+1); if (!empty($this->writeCache)) { - $result = $this->crypt->symmetricEncryptFileContent($this->writeCache, $this->fileKey, $this->version+1, $position); + $result = $this->crypt->symmetricEncryptFileContent($this->writeCache, $this->fileKey, $version, $position); $this->writeCache = ''; } $publicKeys = array(); @@ -318,9 +320,11 @@ class Encryption implements IEncryptionModule { // Partial files do not increase the version if(\OC\Files\Cache\Scanner::isPartialFile($this->path)) { - $this->version = $this->version - 1; + $version = $this->version; + } else { + $version = $this->version + 1; } - $encrypted .= $this->crypt->symmetricEncryptFileContent($chunk, $this->fileKey, $this->version+1, $position); + $encrypted .= $this->crypt->symmetricEncryptFileContent($chunk, $this->fileKey, $version, $position); // Remove the chunk we just processed from // $data, leaving only unprocessed data in $data |