php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7359 php_read() function works bad
Submitted: 2000-10-20 02:05 UTC Modified: 2001-06-02 20:59 UTC
From: mmlynarcik at charmed dot sk Assigned:
Status: Closed Package: Sockets related
PHP Version: 4.0.3pl1 OS: Slackware Linux 7.1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mmlynarcik at charmed dot sk
New email:
PHP Version: OS:

 

 [2000-10-20 02:05 UTC] mmlynarcik at charmed dot sk
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;                                                                                                                      
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-06-02 20:59 UTC] sniper@php.net
This should be fixed with PHP 4.0.6, please try the 
latest release candidate:

http://www.php.net/~andi/php-4.0.6RC2.tar.gz

-Jani

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC