varspool / Wrench

A simple PHP WebSocket implementation for PHP 7.1
Do What The F*ck You Want To Public License
596 stars 210 forks source link

Fix off-by-one error in deciding to exit length calculation #63

Closed dominics closed 9 years ago

dominics commented 9 years ago

The foreach starting at line 271 shouldn't be entered unless it is known $this->buffer[$start] through $this->buffer[$end] is set, inclusive (this is the range in the frame that holds the payload length).

Previously, we tested if $end > strlen($this->buffer). Consider the case when $end == strlen($this->buffer): $this->buffer[$end] is not set (because indexes start at zero). We should therefore instead test for $end >= strlen($this->buffer).

Potentially fixes #35 and #61