php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43700 ob_start() changes variables and makes inconsistent serialize
Submitted: 2007-12-29 01:02 UTC Modified: 2008-01-09 13:59 UTC
Votes:4
Avg. Score:4.0 ± 0.7
Reproduced:4 of 4 (100.0%)
Same Version:4 (100.0%)
Same OS:2 (50.0%)
From: skrol29 at freesurf dot fr Assigned:
Status: Closed Package: Output Control
PHP Version: 5.2.5 OS: any
Private report: No CVE-ID: None
 [2007-12-29 01:02 UTC] skrol29 at freesurf dot fr
Description:
------------
I call two functions, the one after the other. The first one is doing an output redirection using ob_start(). The second one is just modifying a variable. It is like the second function is executed just after the ob_start() without waiting for the end of the first function. The second function is called on an arbitrary local variable, for which the serialization becomes inconsistent.

This bug has been found on PHP 5.2.5, but also 5.2.4, on Linux, Windows XP and Vista.

Reproduce code:
---------------
$Txt = '';
f_Action1($Txt);
f_Action2($Txt);
echo $Txt;

function f_Action1(&$Txt) {
  $z = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  echo "value before={".$z."} <br>\r\n";
  ob_start();
  echo "value after={".$z."} <br>\r\n"; // Bug here : it is like Action2() has been applied to $z
  echo "serialize={".serialize($z)."} <br>\r\n"; // Bug here : the serialization is inconsistent between size and value.
  $Txt = ob_get_contents();
  ob_end_clean();
}

function f_Action2(&$Txt) {
  $Txt = str_replace('ABCDEFGHIJKLMNOPQRSTUVWXYZ','abc',$Txt);
}


Expected result:
----------------
value before={ABCDEFGHIJKLMNOPQRSTUVWXYZ}
value after={ABCDEFGHIJKLMNOPQRSTUVWXYZ}
serialize={s:26:"ABCDEFGHIJKLMNOPQRSTUVWXYZ";} 

Actual result:
--------------
value before={ABCDEFGHIJKLMNOPQRSTUVWXYZ}
value after={abc}
serialize={s:26:"abc";} 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-09 13:59 UTC] skrol29 at freesurf dot fr
there is no bu in this process
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 24 07:02:12 2024 UTC