From: travian dot utils at gmail dot com Operating system: FreeBSD 7.2-RELEASE-p4 amd64 PHP version: 5.2.11 PHP Bug Type: Sockets related Bug description: feof() reached while reading big HTTP response from socket using fgets.
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 bug report at http://bugs.php.net/?id=49838&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=49838&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=49838&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=49838&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=49838&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=49838&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=49838&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=49838&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=49838&r=needscript Try newer version: http://bugs.php.net/fix.php?id=49838&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=49838&r=support Expected behavior: http://bugs.php.net/fix.php?id=49838&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=49838&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=49838&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=49838&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49838&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=49838&r=dst IIS Stability: http://bugs.php.net/fix.php?id=49838&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=49838&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=49838&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=49838&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=49838&r=mysqlcfg