php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20583 Variable values inconsistent with assignment statements.
Submitted: 2002-11-22 12:58 UTC Modified: 2003-04-21 09:17 UTC
Votes:13
Avg. Score:4.6 ± 0.7
Reproduced:12 of 13 (92.3%)
Same Version:7 (58.3%)
Same OS:6 (50.0%)
From: jseverson at myersinternet dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 4CVS-2002-11-22 (stable) OS: RedHat 7.2
Private report: No CVE-ID: None
 [2002-11-22 12:58 UTC] jseverson at myersinternet dot com
I haven't been able to recreate this problem at all in a controlled environment, but I can recreate it consistently where we originally discovered it. 

Here is the snidbit of the function causing the erroneous output:
_______________________________________________________
function do_mail_command($cmd,$server="morpheus.myersinternet.com") {

print "values prior to setting are:<p> server => $server<br>errno => $errno<br>errstr => $errstr<br>whoknows => $whoknows<br>";

if(empty($server)) {
  print "<br>server is empty, so changing values<p>";
  		$server = "this is the first one";
  		$errno = "here is the second one";
  		$errstr = "but they will all be this";
  		$random_variable = "does this work";
	  	print "values after setting:<p> server => $server<br>errno => $errno<br>errstr => $errstr<br>whoknows => $whoknows";
  	}

    $fp = fsockopen($server, 5154, $errno, $errstr, 10);
_________________________________________________________

Here is the output of that exact piece of code:

values prior to setting are:
server => morpheus.myersinternet.com
errno => morpheus.myersinternet.com
errstr => morpheus.myersinternet.com
whoknows => morpheus.myersinternet.com

server is empty, so changing values

values after setting:

server => does this work
errno => does this work
errstr => does this work
whoknows => does this work

____________________________________________________

There are three main problems I see occurring here.

1. The first print statement prints out a bunch of "random" variables, $server being the only that has previously been given a value. However, as the print statement shows, they ALL have values.

2. The empty($server) check returns true even though its obviously clear that $server is NOT empty.

3. After performing variuos assignment statements within the if block, and printing out the variable values, it's clear that ALL the variables receive the value of the LAST assignment statement made.

We found this bug because when calling fsockopen, the $errno and $errstr variables had values even though they were never assigned any values and it was causing the function to fail when trying to open the socket. This function was working fine prior to our upgrade to the latest version.

Our configure line is:
LoadModule php4_module modules/libphp4.so

We are also heavily using session variables in case that helps to recreate the bug.

Thanks

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-21 17:16 UTC] moriyoshi@php.net
Bug #22367 is kind of similar to this bug.

 [2003-03-25 17:40 UTC] jseverson at myersinternet dot com
This bug is related to or the same as the following bugs:

<a href="http://bugs.php.net/bug.php?id=21312">21312</a>
<a href="http://bugs.php.net/bug.php?id=22367">22367</a>
<a href="http://bugs.php.net/bug.php?id=22836">22836</a>
<a href="http://bugs.php.net/bug.php?id=22117">22117</a>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 13:01:29 2024 UTC