php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37096 referencing bug with return value for stream_seek
Submitted: 2006-04-16 02:29 UTC Modified: 2011-08-30 11:46 UTC
From: wez@php.net Assigned:
Status: Not a bug Package: Streams related
PHP Version: 5CVS-2006-04-16 (CVS) OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: wez@php.net
New email:
PHP Version: OS:

 

 [2006-04-16 02:29 UTC] wez@php.net
Description:
------------
When using user-space streams via stream_wrapper_register(),
if you return the value of a property of the object from stream_seek(), it gets mangled.

Sounds like a problem with the way that the retval from call_user_function_ex() is disposed.

The workaround is to create a temporary value using a trick like this:

function stream_seek($offset, $whence) {
   ...
   $retval = $this->pos + 0;
   return $retval;
}

presumably the rest of the user wrapper code has the same flaw.

Reproduce code:
---------------
Abbreviated example; my actual test case is too large.
Valgrind does not indicate any memory errors, so the problem  is likely logical rather than sloppy memory handling.

class MyStream {
  var $this->pos = 0;
 
  function stream_tell() {
    return $this->pos;
  }

  function stream_seek($offset, $whence) {
    return $this->pos;
  }
}


Actual result:
--------------
Problem manifested for me by converting $this->pos to bool(true), which was then interpreted by the user space wrapper as an invalid return value from stream_tell(), which simply returns $this->pos.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-07-26 09:21 UTC] tendencies at free dot fr
See this bug : http://bugs.php.net/bug.php?id=30157
 [2006-09-08 21:04 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2006-09-16 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2010-06-13 14:51 UTC] felipe@php.net
-Status: No Feedback +Status: Open
 [2011-08-30 11:46 UTC] bjori@php.net
-Status: Open +Status: Bogus
 [2011-08-30 11:46 UTC] bjori@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

I can't reproduce this.
If you are still able to produce this, please provide a proper full reproduce 
script
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 23:01:27 2024 UTC