adoy / PHP-FastCGI-Client

Lightweight, single file, FastCGI client for PHP
MIT License
302 stars 61 forks source link

fread() implementation #11

Open langemeijer opened 8 years ago

langemeijer commented 8 years ago

I've read the readPacket private function and found the implementation way to naive to be used in production systems.

When $packet = fread($this->_sock, self::HEADER_LEN) is called on line 382 the returned value is considered to be either false or a 8 byte string. In reality this string can have any length up to 8 bytes.

This problem does not occur when reading the content, because reading won't stop until $resp['contentLength'] bytes are read, but the fread($this->_sock, $resp['paddingLength']) call suffers from the same problem.