aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Files/Stream
diff options
context:
space:
mode:
authormartink-p <47943787+martink-p@users.noreply.github.com>2019-06-13 13:21:16 +0200
committermartink-p <47943787+martink-p@users.noreply.github.com>2019-06-17 12:13:29 +0200
commit4b9675df6c6b5d359b5cf182080aa28b220739f9 (patch)
tree68dfd23957837d2edea1625196224faae16a8d1b /lib/private/Files/Stream
parent452d7696ff7e663f1794742d9708bb62a2771097 (diff)
downloadnextcloud-server-4b9675df6c6b5d359b5cf182080aa28b220739f9.tar.gz
nextcloud-server-4b9675df6c6b5d359b5cf182080aa28b220739f9.zip
Update Encryption.php
Signed-off-by: martink-p <47943787+martink-p@users.noreply.github.com>
Diffstat (limited to 'lib/private/Files/Stream')
-rw-r--r--lib/private/Files/Stream/Encryption.php21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/private/Files/Stream/Encryption.php b/lib/private/Files/Stream/Encryption.php
index 3c884a99ae7..bdbbc8a06ff 100644
--- a/lib/private/Files/Stream/Encryption.php
+++ b/lib/private/Files/Stream/Encryption.php
@@ -315,6 +315,23 @@ class Encryption extends Wrapper {
return $result;
}
+
+ /**
+ * stream_read wrapper to read complete requested block
+ */
+ private function stream_read_block($blockSize) {
+ $remaining = $blockSize;
+ $data = "";
+
+ do {
+ $chunk = parent::stream_read($remaining);
+ $chunk_len = strlen($chunk);
+ $data .= $chunk;
+ $remaining -= $chunk_len;
+ } while ( ($remaining > 0) && ($chunk_len > 0) );
+
+ return $data;
+ }
public function stream_write($data) {
$length = 0;
@@ -470,7 +487,7 @@ class Encryption extends Wrapper {
// don't try to fill the cache when trying to write at the end of the unencrypted file when it coincides with new block
if ($this->cache === '' && !($this->position === $this->unencryptedSize && ($this->position % $this->unencryptedBlockSize) === 0)) {
// Get the data from the file handle
- $data = parent::stream_read($this->util->getBlockSize());
+ $data = $this->stream_read_block($this->util->getBlockSize());
$position = (int)floor($this->position/$this->unencryptedBlockSize);
$numberOfChunks = (int)($this->unencryptedSize / $this->unencryptedBlockSize);
if($numberOfChunks === $position) {
@@ -495,7 +512,7 @@ class Encryption extends Wrapper {
* read first block to skip the header
*/
protected function skipHeader() {
- parent::stream_read($this->headerSize);
+ $this->stream_read_block($this->headerSize);
}
/**