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

This commit is contained in:
Bjoern Schiessle 2016-02-09 20:05:07 +01:00 committed by Lukas Reschke
parent 3736f13826
commit 377d7fb8a8
1 changed files with 8 additions and 4 deletions

View File

@ -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