PHP 4.0 Bug #7359: php_read() function works bad

From: Date: Fri, 20 Oct 2000 06:05:30 +0000
Subject: PHP 4.0 Bug #7359: php_read() function works bad
Groups: php.dev 
Request: Send a blank email to php-dev+get-35619@lists.php.net to get a copy of this message
From: mmlynarcik@charmed.sk Operating system: Slackware Linux 7.1 PHP version: 4.0.3pl1 PHP Bug Type: Sockets related Bug description: php_read() function works bad Here is correct function : int php_read(int fd, void *buf, int maxlen) { char *t; int m = 0, n = 0; int no_read = 0; errno = 0; t = (char *) buf; while (*t != '\n' && *t != '\r' && *t != '\0' && n < maxlen) { m = read(fd, (void *) t, 1); if (m > 0) { t++; n++; } else if (m == 0) { no_read++; if (no_read > 200) { errno = ECONNRESET; return -1; } } if (errno != 0 && errno != ESPIPE && errno != EAGAIN) { return -1; } errno = 0; } return n; } -- Edit Bug report at: http://bugs.php.net/?id=7359&edit=1

« previous php.dev (#35619) next »