#21760 [Com]: socket_read PHP_NORMAL_READ problem

From: Date: Wed, 05 Feb 2003 15:53:05 +0000
Subject: #21760 [Com]: socket_read PHP_NORMAL_READ problem
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-32197@lists.php.net to get a copy of this message
ID: 21760 Comment by: uce@ftc.gov Reported By: sunday@csh.rit.edu Status: Open Bug Type: Sockets related Operating System: FreeBSD 4.7 PHP Version: 4.3.0 New Comment: 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++; Previous Comments: ------------------------------------------------------------------------ [2003-01-19 23:18:44] sunday@csh.rit.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. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=21760&edit=1

« previous php.bugs (#32197) next »