PHP :: Bug #21760 :: socket_read PHP_NORMAL_READ problem
| Bug #21760 | socket_read PHP_NORMAL_READ problem | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2003-01-19 23:18 UTC | Modified: | 2004-02-25 17:04 UTC |
|
||||||||||
| From: | sunday at csh dot rit dot edu | Assigned: | ||||||||||||
| Status: | Closed | Package: | Sockets related | |||||||||||
| PHP Version: | 4.3.0 | OS: | FreeBSD 4.7 | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2003-01-19 23:18 UTC] sunday at csh dot rit dot edu
$string = socket_read( $socket, 100, PHP_NORMAL_READ ); will return a "\n" after several reads, and continue to return "\n" in an infinite loop rather than the rest of the buffer. The server it's reading from sends a large multi-line (lines terminated with "\n") packet (~7500 bytes) in one write() call. After reading through about half of it with the line above, socket_read will start returning bad data about 10% - 20% of the time.
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2003-02-05 09:53 UTC] uce at ftc dot gov
I believe this is caused by a comparison to an uninitialized buffer in php_read (buffer emalloc'd in socket_read). Patch: --- php5/ext/sockets/sockets.c 2003-01-18 19:28:06.000000000 +0000 +++ php5-atropine/ext/sockets/sockets.c 2003-02-05 15:43:00.000000000 +0000 @@ -288,6 +288,7 @@ set_errno(0); + *t = 0; while (*t != '\n' && *t != '\r' && n < maxlen) { if (m > 0) { t++;[2003-02-05 21:08 UTC] chip at cyan dot com
[2004-02-24 08:43 UTC] eriksson@php.net
[2004-02-25 17:04 UTC] iliaa@php.net