From 377d7fb8a817f337552e444c5aea9eb82bcfada4 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Tue, 9 Feb 2016 20:05:07 +0100 Subject: [PATCH] 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 --- apps/encryption/lib/crypto/encryption.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/encryption/lib/crypto/encryption.php b/apps/encryption/lib/crypto/encryption.php index 403b617c5b..645d17f818 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