From:             stuff at axxess dot co dot za
Operating system: Linux
PHP version:      5.2.6
PHP Bug Type:     Filesystem function related
Bug description:  feof(FALSE) should return TRUE

Description:
------------
feof(bad_fd) returns FALSE, which indicates that the file descriptor 
has more data.  This is wrong in *every* case.  It should return 
TRUE (no more data), or throw a fatal error.  More than a few sloppy 
fools fail to test the result of fopen(), and blow your bandwidth 
cap and/or hosting budget for a year by serving warnings when your 
RSS source changes their DNS name. 

Reproduce code:
---------------
<?php
$f = fopen ("http://dns.err/foo.html","r";);  # ie. $f=FALSE
while (!feof ($f)) {                         # ie. !feof(FALSE)
  $verse .= fgets($f, 4096);
}
fclose ($f);
echo "DONE";


Expected result:
----------------
Warning: fopen(): php_network_getaddresses: getaddrinfo failed: Name 
or service not known in /home/andrewm/x.php on line 2

Warning: fopen(http://dns.err/foo.html): failed to open stream: No 
such file or directory in /home/andrewm/x.php on line 2

Warning: feof(): supplied argument is not a valid stream resource 
in /home/andrewm/x.php on line 3
DONE

Actual result:
--------------
Warning: fopen(): php_network_getaddresses: getaddrinfo failed: Name 
or service not known in /home/andrewm/x.php on line 2

Warning: fopen(http://dns.err/foo.html): failed to open stream: No 
such file or directory in /home/andrewm/x.php on line 2

Warning: feof(): supplied argument is not a valid stream resource 
in /home/andrewm/x.php on line 3

Warning: fgets(): supplied argument is not a valid stream resource 
in /home/andrewm/x.php on line 4

Warning: feof(): supplied argument is not a valid stream resource 
in /home/andrewm/x.php on line 3

Warning: fgets(): supplied argument is not a valid stream resource 
in /home/andrewm/x.php on line 4

Warning: feof(): supplied argument is not a valid stream resource 
in /home/andrewm/x.php on line 3

Warning: fgets(): supplied argument is not a valid stream resource 
in /home/andrewm/x.php on line 4

Warning: feof(): supplied argument is not a valid stream resource 
in /home/andrewm/x.php on line 3

Warning: fgets(): supplied argument is not a valid stream resource 
in /home/andrewm/x.php on line 4

(warnings continue ad-infinitum)

-- 
Edit bug report at http://bugs.php.net/?id=45759&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=45759&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=45759&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=45759&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=45759&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=45759&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=45759&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=45759&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=45759&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=45759&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=45759&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=45759&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=45759&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=45759&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=45759&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=45759&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=45759&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=45759&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=45759&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=45759&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=45759&r=mysqlcfg

Reply via email to