From:             amoo_miki at yahoo dot com
Operating system: Win32
PHP version:      5.2.5
PHP Bug Type:     Streams related
Bug description:  stream_get_line not working as expected

Description:
------------
On some occasions stream_get_line acts weired by attempting the first seek
without considering the "end of line" string.

Below is the sample code that shows the problem with a workaround to
temporarily solve the issue (that might ring some bells for the person who
plans on fixing this).

The code uses a small binary JPX file that can be fetched from
http://barahmand.com/streambug/sample.txt

Reproduce code:
---------------
<?php 
$filename = 'sample.txt';
$arr = explode('<EndOfFrame>', file_get_contents($filename));
echo "Found in source at ".strlen($arr[0])."\n\n";
$fp = fopen($filename, "rb");
stream_get_line($fp, 15000, "<EndOfFrame>");
echo "Location in stream: ".ftell($fp)."\n";
echo "Rewinding...\n"; rewind($fp);
stream_get_line($fp, 15000, "<EndOfFrame>");
echo "Location in stream: ".ftell($fp)."\n";
rewind($fp);
echo "\nAttempting fix...\n";
stream_get_line($fp, 1, "<EndOfFrame>");
stream_get_line($fp, 15000, "<EndOfFrame>");
echo "Location in stream: ".ftell($fp)."\n";
echo "Rewinding...\n"; rewind($fp);
stream_get_line($fp, 15000, "<EndOfFrame>");
echo "Location in stream: ".ftell($fp)."\n";
fclose($fp);
?>

Expected result:
----------------
Found in source at 9295

Location in stream: 9307
Rewinding...
Location in stream: 9307

Attempting fix...
Location in stream: 9307
Rewinding...
Location in stream: 9307

Actual result:
--------------
Found in source at 9295

Location in stream: 15000
Rewinding...
Location in stream: 15000

Attempting fix...
Location in stream: 9307
Rewinding...
Location in stream: 9307

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

Reply via email to