Edit report at https://bugs.php.net/bug.php?id=63240&edit=1

 ID:                 63240
 Updated by:         datib...@php.net
 Reported by:        scope at planetavent dot de
 Summary:            stream_get_line return contains delimiter string
 Status:             Closed
 Type:               Bug
 Package:            Streams related
 Operating System:   Windows Server 2008 / RHEL 6.2
 PHP Version:        5.3.17
 Assigned To:        cataphract
 Block user comment: N
 Private report:     N

 New Comment:

Is it tomorrow yet? :)


Previous Comments:
------------------------------------------------------------------------
[2012-10-12 18:23:20] cataphr...@php.net

Automatic comment on behalf of glo...@nebm.ist.utl.pt
Revision: 
http://git.php.net/?p=php-src.git;a=commit;h=76601c4fd1052bd46e8db4addb1bb9dd3b001f98
Log: Fix bug #63240 on stream_get_line()

------------------------------------------------------------------------
[2012-10-09 21:14:04] cataphr...@php.net

Thanks, I'll commit this tomorrow.

As to your other comment on the list about the bool(false) return instead of an 
empty string for an empty file, that was a bug fix. A return of "" would 
indicate an empty line. The result is now corect:

$ php -r '$fd = fopen("php://temp", "r+"); var_dump(stream_get_line($fd, 10, 
"MM"));'
bool(false)
$ php -r '$fd = fopen("php://temp", "r+"); fwrite($fd, "MM"); rewind($fd); 
var_dump(stream_get_line($fd, 10, "MM"), stream_get_line($fd, 10, "MM"));
string(0) ""
bool(false)

------------------------------------------------------------------------
[2012-10-09 09:02:54] datib...@php.net

Added a patch that will apply to 5.4.4

------------------------------------------------------------------------
[2012-10-09 09:02:18] datib...@php.net

The following patch has been added/updated:

Patch Name: getrecord-delimiter-search-fix
Revision:   1349773338
URL:        
https://bugs.php.net/patch-display.php?bug=63240&patch=getrecord-delimiter-search-fix&revision=1349773338

------------------------------------------------------------------------
[2012-10-09 03:35:35] datib...@php.net

Reduced test:

  $file = __DIR__ . '/input_dummy.txt';
  $data = str_repeat( '.', 8189 ) . 'MMMM';
  file_put_contents( $file, $data );
  $fh = fopen( $file, "rb" );
  $delimiter = "MM";

  stream_get_line($fh, 4096, $delimiter);
  stream_get_line($fh, 4096, $delimiter);
  if ($delimiter === stream_get_line($fh, 4096, $delimiter)) {
    echo "BROKEN";
  } else {
    echo "OK";
  }
  fclose($fh);
  unlink($file);

The amount of dots seems to be related to the used buffer length:

(<number-of-dots> + 3) % (<buffer-length> x 2) == 0

The length of the delimiter also seems to play a role, but I'm not sure what 
that would be.

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


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

    https://bugs.php.net/bug.php?id=63240


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63240&edit=1

Reply via email to