From:             ryan dot brothers at gmail dot com
Operating system: Linux
PHP version:      5.2.9
PHP Bug Type:     Streams related
Bug description:  stream_get_line() - invalid result when passing $length and 
$ending

Description:
------------
When you pass to stream_get_line() a $length that is greater than the file
size and a $ending that does not appear in the file, stream_get_line()
returns bool(false) rather than the string that is in your file.

In the below example, when I run stream_get_line() passing in a $length of
6 and a $ending of "\n", stream_get_line() returns false rather than the
contents of the file.

The manual states "Reading ends when length bytes have been read, when the
string specified by ending is found (which is not included in the return
value), or on EOF (whichever comes first).", so I believe the contents of
my file should be returned since EOF is first to be reached.

Reproduce code:
---------------
<?php
$fp = tmpfile();

fwrite($fp, '12345');

fseek($fp, 0);
var_dump(stream_get_line($fp, 5));

fseek($fp, 0);
var_dump(stream_get_line($fp, 6));

fseek($fp, 0);
var_dump(stream_get_line($fp, 5, "\n"));

fseek($fp, 0);
var_dump(stream_get_line($fp, 6, "\n"));

fclose($fp);


Expected result:
----------------
string(5) "12345"
string(5) "12345"
string(5) "12345"
string(5) "12345"


Actual result:
--------------
string(5) "12345"
string(5) "12345"
string(5) "12345"
bool(false)


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

Reply via email to