From: tylera at iproduction dot com
Operating system: Gentoo Linux, Win32, Solaris
PHP version: 5.2.5
PHP Bug Type: Streams related
Bug description: stream_get_line eats additional characters
Description:
------------
Calling stream_get_line may eat additional characters when reading a long
line. If the delimiter is not encountered, a number of additional
characters are removed from the stream and are not returned with the next
call to stream_get_line. For some unknown reason, adding \r to the
delimiter makes it work just fine.
Reproduce code:
---------------
<?PHP // 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ
$fp = fopen('test.php', 'r'); // Open myself
DoTest($fp, 'ZZZ'); // Removes 3 characters
DoTest($fp, "\r"); // Doesn't break with \r for some reason
function DoTest($fp, $delim) {
echo "Delim: " . urlencode($delim) . "\n";
rewind($fp);
echo " " . stream_get_line($fp, 10, $delim) . "\n";
echo " " . stream_get_line($fp, 10, $delim) . "\n";
}
Expected result:
----------------
Delim: ZZZ
<?PHP // 1
234567890A
Delim: %0D
<?PHP // 1
234567890A
Actual result:
--------------
Delim: ZZZ
<?PHP // 1
567890ABCD
Delim: %0D
<?PHP // 1
234567890A
--
Edit bug report at http://bugs.php.net/?id=43522&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=43522&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=43522&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=43522&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=43522&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=43522&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=43522&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=43522&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=43522&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=43522&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=43522&r=support
Expected behavior: http://bugs.php.net/fix.php?id=43522&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=43522&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=43522&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=43522&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43522&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=43522&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=43522&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=43522&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=43522&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=43522&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=43522&r=mysqlcfg