diff options
author | Björn Schießle <bjoern@schiessle.org> | 2015-05-18 19:26:40 +0200 |
---|---|---|
committer | Björn Schießle <bjoern@schiessle.org> | 2015-05-18 19:26:40 +0200 |
commit | 1c411baf17467f6d754c390317a775e685416aa1 (patch) | |
tree | 11df14d05f8615c9c8fe1728f9892c764f16218e | |
parent | b085f5855362bb8c305083c1d60ebfd459323a96 (diff) | |
parent | 1c500487ba33b5218929d08a6c95fd1096f7f9ce (diff) | |
download | nextcloud-server-1c411baf17467f6d754c390317a775e685416aa1.tar.gz nextcloud-server-1c411baf17467f6d754c390317a775e685416aa1.zip |
Merge pull request #16412 from owncloud/jknockaert-patch-1
fix #16356
-rw-r--r-- | lib/private/files/stream/encryption.php | 2 | ||||
-rw-r--r-- | tests/lib/files/stream/encryption.php | 12 |
2 files changed, 11 insertions, 3 deletions
diff --git a/lib/private/files/stream/encryption.php b/lib/private/files/stream/encryption.php index e423868d82b..f2f5b9c9af7 100644 --- a/lib/private/files/stream/encryption.php +++ b/lib/private/files/stream/encryption.php @@ -341,8 +341,8 @@ class Encryption extends Wrapper { } else { $data = ''; } + $this->unencryptedSize = max($this->unencryptedSize, $this->position); } - $this->unencryptedSize = max($this->unencryptedSize, $this->position); return $length; } diff --git a/tests/lib/files/stream/encryption.php b/tests/lib/files/stream/encryption.php index 30c6d247236..c2388c7682a 100644 --- a/tests/lib/files/stream/encryption.php +++ b/tests/lib/files/stream/encryption.php @@ -7,6 +7,9 @@ use OCA\Encryption_Dummy\DummyModule; class Encryption extends \Test\TestCase { + /** @var \OCP\Encryption\IEncryptionModule | \PHPUnit_Framework_MockObject_MockObject */ + private $encryptionModule; + /** * @param string $fileName * @param string $mode @@ -21,7 +24,7 @@ class Encryption extends \Test\TestCase { $fullPath = $fileName; $header = []; $uid = ''; - $encryptionModule = $this->buildMockModule(); + $this->encryptionModule = $this->buildMockModule(); $storage = $this->getMockBuilder('\OC\Files\Storage\Storage') ->disableOriginalConstructor()->getMock(); $encStorage = $this->getMockBuilder('\OC\Files\Storage\Wrapper\Encryption') @@ -43,7 +46,7 @@ class Encryption extends \Test\TestCase { ->willReturn(['user1', $internalPath]); return \OC\Files\Stream\Encryption::wrap($source, $internalPath, - $fullPath, $header, $uid, $encryptionModule, $storage, $encStorage, + $fullPath, $header, $uid, $this->encryptionModule, $storage, $encStorage, $util, $file, $mode, $size, $unencryptedSize, 8192); } @@ -221,10 +224,15 @@ class Encryption extends \Test\TestCase { * @dataProvider dataFilesProvider */ public function testWriteReadBigFile($testFile) { + $expectedData = file_get_contents(\OC::$SERVERROOT . '/tests/data/' . $testFile); // write it $fileName = tempnam("/tmp", "FOO"); $stream = $this->getStream($fileName, 'w+', 0); + // while writing the file from the beginning to the end we should never try + // to read parts of the file. This should only happen for write operations + // in the middle of a file + $this->encryptionModule->expects($this->never())->method('decrypt'); fwrite($stream, $expectedData); fclose($stream); |