#44607 [Opn]: stream_get_line unable to correctly identify the "ending" in the stream content

[email protected] ("amoo_miki at yahoo dot com")
Newsgroups php.bugs
Message-ID <[email protected]>
 ID:               44607
 User updated by:  amoo_miki at yahoo dot com
-Summary:          stream_get_line return incorrect values
 Reported By:      amoo_miki at yahoo dot com
 Status:           Open
 Bug Type:         Streams related
 Operating System: *
-PHP Version:      5.x upto 5.3-alpha2 and even 6.0
+PHP Version:      5.2.5, 5.2.6, 5.2.7-dev, 5.3-alpha1, 6.0.0-dev
 New Comment:

Doing some more investigation:

if the "ending" is just a character, the function works fine and return
the correct value, always.

stream_get_line in ./ext/standard/streamfuncs.c passes the action to
php_stream_get_record in ./main/streams/streams.c where there is an
explicit condition:
if delim_len == 1 the result is directly fetched using memchr() else
php_memnstr() is requested to process the stream.
./main/php.h defines php_memnstr as zend_memnstr, and looking at
./Zend/zend_operatprs.h the function zend_memnstr uses memchr() and
memcmp() and I should suspect something going wrong there.

The patch that sometimes forces the function to work correctly is a
proof that all these functions work correct but there is a variable
whose value is not being set correctly, ie not being initialized
(maybe?)

Anyway, this function is a very useful one and it's really unfortunate
that it has not been fixed in almost 5 months.


Previous Comments:
------------------------------------------------------------------------

[2008-08-19 15:30:10] amoo_miki at yahoo dot com

I just got PHP 6.0.0-dev (built: Jul 28 2008 02:06:04) also configured
and installed. that too has this problem of not working correctly.

------------------------------------------------------------------------

[2008-08-19 15:24:58] amoo_miki at yahoo dot com

The bug still persists.

------------------------------------------------------------------------

[2008-07-14 21:54:02] amoo_miki at yahoo dot com

I should also add that the workaround (that works for this example
file) does not always work.

------------------------------------------------------------------------

[2008-07-14 21:45:58] amoo_miki at yahoo dot com

Also tried with the latest CVS snapshot of 5.2.7-dev and it still gives
incorrect results.

------------------------------------------------------------------------

[2008-07-14 21:30:22] amoo_miki at yahoo dot com

Tested this with PHP v5.2.6 on Windows 2008 Server and FreeBSD 7.0 and
it still returns incorrect results.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/44607

-- 
Edit this bug report at http://bugs.php.net/?id=44607&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.