From c830685f5f2c8aad00ab151a3f8206faefd23b41 Mon Sep 17 00:00:00 2001 From: Niels Theen Date: Mon, 13 Feb 2017 16:15:14 +0100 Subject: [PATCH] Fix Endless loop Fix --- src/ChunkedDecoder.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ChunkedDecoder.php b/src/ChunkedDecoder.php index e6027465..8c367509 100644 --- a/src/ChunkedDecoder.php +++ b/src/ChunkedDecoder.php @@ -95,21 +95,21 @@ public function handleData($data) return; } - $hexValue = strtolower(substr($this->buffer, 0, $positionClrf)); + $hexValue = strtolower((string)substr($this->buffer, 0, $positionClrf)); if (dechex(hexdec($hexValue)) !== $hexValue || hexdec($hexValue) > 2147483647) { $this->handleError(new \Exception($hexValue . ' is not a hexadecimal number or too big')); return; } $this->chunkSize = hexdec($hexValue); - $this->buffer = substr($this->buffer, strlen($hexValue) + 2); + $this->buffer = (string)substr($this->buffer, strlen($hexValue) + 2); $this->headerCompleted = true; if ($this->buffer === '') { return; } } - $chunk = substr($this->buffer, 0, $this->chunkSize - $this->transferredSize); + $chunk = (string)substr($this->buffer, 0, $this->chunkSize - $this->transferredSize); if ($chunk !== '') { $this->transferredSize += strlen($chunk); if ($this->transferredSize > $this->chunkSize) { @@ -118,7 +118,7 @@ public function handleData($data) } $this->emit('data', array($chunk)); - $this->buffer = substr($this->buffer, strlen($chunk)); + $this->buffer = (string)substr($this->buffer, strlen($chunk)); } if (strpos($this->buffer, static::CRLF) !== false) { @@ -132,7 +132,7 @@ public function handleData($data) $this->chunkSize = 0; $this->headerCompleted = false; $this->transferredSize = 0; - $this->buffer = substr($this->buffer, 2); + $this->buffer = (string)substr($this->buffer, 2); } } }