diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-10-01 18:12:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-01 18:12:49 +0200 |
commit | 8743fe6bbac350eaa5ad978de5c163fb892a7f6d (patch) | |
tree | b25e1855c88272081d0decc97994e1ea6b610088 /apps/dav/lib/Upload | |
parent | e1606d1a027c8e84b4ce4dca13051f9a73b47873 (diff) | |
parent | f1f74a39b6ab830e6e70c5df93395442a4c4a886 (diff) | |
download | nextcloud-server-8743fe6bbac350eaa5ad978de5c163fb892a7f6d.tar.gz nextcloud-server-8743fe6bbac350eaa5ad978de5c163fb892a7f6d.zip |
Merge pull request #11435 from nextcloud/assemblystream-node-to-small
throw an error if a node is smaller than expected in assemblystream
Diffstat (limited to 'apps/dav/lib/Upload')
-rw-r--r-- | apps/dav/lib/Upload/AssemblyStream.php | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/apps/dav/lib/Upload/AssemblyStream.php b/apps/dav/lib/Upload/AssemblyStream.php index 3ba24bf60fd..24417851f2f 100644 --- a/apps/dav/lib/Upload/AssemblyStream.php +++ b/apps/dav/lib/Upload/AssemblyStream.php @@ -57,6 +57,9 @@ class AssemblyStream implements \Icewind\Streams\File { /** @var int */ private $currentNode = 0; + /** @var int */ + private $currentNodeRead = 0; + /** * @param string $path * @param string $mode @@ -110,10 +113,16 @@ class AssemblyStream implements \Icewind\Streams\File { do { $data = fread($this->currentStream, $count); $read = strlen($data); + $this->currentNodeRead += $read; if (feof($this->currentStream)) { fclose($this->currentStream); + $currentNodeSize = $this->nodes[$this->currentNode]->getSize(); + if ($this->currentNodeRead < $currentNodeSize) { + throw new \Exception('Stream from assembly node shorter than expected, got ' . $this->currentNodeRead . ' bytes, expected ' . $currentNodeSize); + } $this->currentNode++; + $this->currentNodeRead = 0; if ($this->currentNode < count($this->nodes)) { $this->currentStream = $this->getStream($this->nodes[$this->currentNode]); } else { |