Skip to content

Commit

Permalink
Fix Endless loop
Browse files Browse the repository at this point in the history
Fix
  • Loading branch information
legionth committed Feb 13, 2017
1 parent 7d49a55 commit c830685
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/ChunkedDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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);
}
}
}
Expand Down

0 comments on commit c830685

Please sign in to comment.