diff options
author | Robin Appelman <robin@icewind.nl> | 2018-09-28 15:40:08 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2018-10-02 20:31:45 +0200 |
commit | 90fa65900baf0d5ebd5abcb804039b0be94b7aec (patch) | |
tree | 44c04281038a0f30c3388de88494ac2a21df0d31 | |
parent | 27323c977f0da690fd02396a42ac70bfdd38d6d3 (diff) | |
download | nextcloud-server-90fa65900baf0d5ebd5abcb804039b0be94b7aec.tar.gz nextcloud-server-90fa65900baf0d5ebd5abcb804039b0be94b7aec.zip |
throw an error if a node is smaller than expected in assemblystream
Signed-off-by: Robin Appelman <robin@icewind.nl>
-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 { |