PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Networking » Net_Server » Bug #1429

readFromSocket fails on \'0\'

Details

Submitted2004-05-18 07:51 UTC
Fromrick at gibbed dot us
Assignedschst
StatusClosed
PackageNet_Server
PHP Version4.3.6
OSLinux
Roadmaps(Not assigned)

Comments

[2004-05-18 07:51 UTC] rick at gibbed dot us

Description:
------------
If '0' (by itself?) is sent to the Net_Server server, the client will be dropped as if the client had sent an empty data package, this is due to an improper checking of the data that socket_read returns in Driver.php. It also fails in Driver/Sequential.php when checking for an empty data package.

Fixes are provided.

The fix for Driver/Fork.php is untested.

Reproduce code:
---------------
(affected line ~172 in Driver.php)
while($buf = socket_read($this->clientFD[$clientId], $this->readBufferSize)) {

(fixed version)
while(($buf = socket_read($this->clientFD[$clientId], $this->readBufferSize, PHP_BINARY_READ)) !== false) {

(affected line ~155 in Driver/Sequential.php)
if (!$data) {

(fixed version)
if (trim($data) == "") {

(affected line ~175)
if (!$data) {

(fixed version)
if (trim($data) == "") {

Expected result:
----------------
Not to close the connection on me ;-)

Actual result:
--------------
Closes connection.

"Connection closed by peer."

[2004-05-18 07:52 UTC] rick at gibbed dot us

(affected line ~175) should be (affected line ~175 in Driver/Fork.php)