#41516 [NEW]: fgets() returns a line of text when length parameter is <= 0
| From: | kraghuba at in dot ibm dot com | Date: | Mon, 28 May 2007 05:08:24 +0000 |
| Subject: | #41516 [NEW]: fgets() returns a line of text when length parameter is <= 0 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-113089@lists.php.net to get a copy of this message | ||
From: kraghuba at in dot ibm dot com
Operating system: Windows XP, Linux
PHP version: 6CVS-2007-05-28 (CVS)
PHP Bug Type: Filesystem function related
Bug description: fgets() returns a line of text when length parameter is <= 0
Description:
------------
fgets() functions returns a line of text form file when length parameter
is <= 0.
fgets() should return a warning message indicating that "length parameter
should be greater than 0" but returns a line of text when length parameter
is <= 0
This failure is only applicable to PHP 6.
Consider adding a check for length parameter in the code after paramerts
are parsed.
if (len <= 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length parameter must be
greater than 0");
RETURN_FALSE;
}
Reproduce code:
---------------
<?php
$fp = fopen(__FILE__, "r");
var_dump( fgets($fp, 0) );
var_dump( fgets($fp, -10) );
fclose($fp);
?>
Expected result:
----------------
Warning: fgets(): Length parameter must be greater than 0 in %s on line
%d
bool(false)
Warning: fgets(): Length parameter must be greater than 0 in %s on line
%d
bool(false)
Actual result:
--------------
string(7) "<?php
"
string(31) " $fp = fopen(__FILE__, "r");
"
--
Edit bug report at http://bugs.php.net/?id=41516&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41516&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41516&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41516&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41516&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=41516&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=41516&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=41516&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=41516&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=41516&r=support
Expected behavior: http://bugs.php.net/fix.php?id=41516&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=41516&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=41516&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41516&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41516&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41516&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=41516&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=41516&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=41516&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=41516&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=41516&r=mysqlcfg