ID:               49838
 User updated by:  travian dot utils at gmail dot com
-Summary:          feof() reached while reading big HTTP response from
                   socket using fgets.
 Reported By:      travian dot utils at gmail dot com
 Status:           Open
 Bug Type:         Sockets related
 Operating System: FreeBSD 7.2-RELEASE-p4 amd64
 PHP Version:      5.2.11
 New Comment:

Corrected summary.


Previous Comments:
------------------------------------------------------------------------

[2009-10-11 17:08:44] travian dot utils at gmail dot com 

Description:
------------
feof() reached end of stream while reading big HTTP response from
socket using fgets.



Reproduce code:
---------------
...
  $fp = @fsockopen ($sname, 80, $errno, $errstr, 18);
  if ($fp) {
    fputs ($fp, "GET /".$xxx." HTTP/1.0\r\nHost:
".$sname."\r\nUser-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0;
en-US; rv:1.9.0.2) Gecko/2008092313 Firefox/3.1.6\r\n\r\n");
    $time='';
    $len='';
    $substr='';
    $upstr='';
    $redirect='';
    $http_code=0;
    while (!feof($fp)) {
      $line=fgets($fp,256);
      $substr=substr($line,0,15);
      $substr2=substr($line,0,10);
      $substr3=substr($line,0,16);
      if(strpos($line, '404 Not Found')!=false){$http_code=404;
break;};
      if($line==chr(13).chr(10))break;
      if($substr2=='Location: '){$redirect=substr($line,10);break;};
      if($substr3=='Content-Length: ')$len=intval(substr($line,16));
      if($substr=='Last-Modified: ')$time=substr($line,15);
    }
    $rlen=0;
        unset($lines);
// This cycle reached end while reading big HTTP response 
    while (!feof($fp)) {
          $line=fgets($fp,1024);
      $lines[]=$line;
      $rlen+=strlen($line);
        }
        //print('$len='.$len);
        //print('$time='.$time);
    $dtin=date('Y-m-d',strtotime($time));
    $time=strtotime($time);
        //print('$dtin='.$dtin);
        //print('$time='.$time);
    if($http_code==404){
      return -10;
    }elseif($dtin==$dt){
      return -2;
    }elseif($time==-1){
      return -3;
    }elseif($redirect!=''){
      return -4;
    }elseif($time==''){
      return -5;
    }elseif(isset($timein)){
      if($time<=$timein){
        return 0;
      }
    }
  }else{
    return -6;
  }
...



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=49838&edit=1

Reply via email to