php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72941 Modifying bucket->data by-ref has no effect any longer
Submitted: 2016-08-25 12:25 UTC Modified: 2020-09-08 13:12 UTC
From: D0L1K at seznam dot cz Assigned: cmb (profile)
Status: Closed Package: Streams related
PHP Version: 7.0.10 OS: Windows 10
Private report: No CVE-ID: None
 [2016-08-25 12:25 UTC] D0L1K at seznam dot cz
Description:
------------
After upgrade PHP from 5.6 to 7.0 the stream_get_contents function with our custom stream filter (php_user_filter) returns non-filtered stream.
After investigations we found that if we pass reference to bucket->data to our decryptor, replace directly char after char (treating string as char array) there and we pass changed bucket object into out brigade, stream_get_contents still returns non-filtered string. Even if we changed bucket->data manually after that chars replace (for ex. bucket->data = "test"), we still get the same output.
But if we pass bucket->data as normal parameter to decryptor, return replaced chars from it and saves them into bucket->data, everything works well.
I've prepared small demonstration of this problem in script using custom filter to rotate left chars in string. In PHP 5.6 it's working normally (output same as it is in "Expected result"), but in 7.0 not.
I looked into 5.6 to 7.0 migration, but didn't see anything related to this problem. Maybe I've missed something, so in that case please just post reference to it and ignore this.

PS: first time reporting bug here, so sorry in case of any mistake or lack of informations. Ofc I will provide any other information if needed

Test script:
---------------
https://mega.nz/#!4VtiwCYB!vrxnr99hj6940uXYXUWAjPHrpcyqscyJjNN7iIkyBVs

Expected result:
----------------
ORIGINAL: hello, world
FILTER1:  ello, worldd
FILTER2:  ello, worldd

Actual result:
--------------
ORIGINAL: hello, world
FILTER1:  hello, world
FILTER2:  ello, worldd

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-10-14 16:25 UTC] cmb@php.net
-Package: Class/Object related +Package: Streams related
 [2020-09-08 13:12 UTC] cmb@php.net
-Summary: Stream filter passing reference of bucket->data returns nonfiltered stream +Summary: Modifying bucket->data by-ref has no effect any longer -Assigned To: +Assigned To: cmb
 [2020-09-08 13:12 UTC] cmb@php.net
I can confirm that change of behavior[1], and assume that just has
been overlooked.  Still, I'm not convinced that we should fix the
regression.

[1] <https://3v4l.org/lQ88Q>
 [2020-09-08 13:19 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #72941: Modifying bucket->data by-ref has no effect any longer
On GitHub:  https://github.com/php/php-src/pull/6096
Patch:      https://github.com/php/php-src/pull/6096.patch
 [2020-09-08 16:12 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5dcb8f2f1cd84cab83b7713efcbafeeb629b8b5b
Log: Fix #72941: Modifying bucket-&gt;data by-ref has no effect any longer
 [2020-09-08 16:12 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 09:01:32 2024 UTC