php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26401 wrong array elements are printed depending on URL parameters
Submitted: 2003-11-25 06:41 UTC Modified: 2003-11-25 15:16 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: bernhard at rainbow dot bksys dot at Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.3.2 OS: debian sarge
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bernhard at rainbow dot bksys dot at
New email:
PHP Version: OS:

 

 [2003-11-25 06:41 UTC] bernhard at rainbow dot bksys dot at
Description:
------------
http://bksys.at/bernhard/phpbug.php?data=123

Only with the URL parameter data set to something,

$data[0] is the first character of the element last inserted
into the array $data[]

and $data[1++) yields the characters of $_REQUEST['data'][1++].

Though I have PHP 4.1.2, this also happened on PHP 4.3.2.



Reproduce code:
---------------
<html><body>
<?php
/*
why does this script print the first character of
$data['foo'] if called with the url parameter
data set to something, e.g. .../test.php?data=123
A bug?

*/

$data['dummy']='nothing';
$data['foo']='bar';
echo '[',$data[null],']';
echo '[',$data[''],']';
echo '[',$data[0],']';
echo '[',$data[1],']';
echo '[',$data[2],']';
echo '[',$data[3],']';
echo '[',$data[-1],']';
echo '[',$data[-2],']';

echo "<pre>";
echo htmlspecialchars(implode('',file($_SERVER['SCRIPT_FILENAME'])));
echo "</pre>";
phpinfo();
?>
</body></html>


Expected result:
----------------
[][][][][][][][]

<html><body>
<?php
/*
why does this script print the first character of
$data['foo'] if called with the url parameter
data set to something, e.g. .../test.php?data=123
A bug?

*/

$data['dummy']='nothing';
$data['foo']='bar';
echo '[',$data[null],']';
echo '[',$data[''],']';
echo '[',$data[0],']';
echo '[',$data[1],']';
echo '[',$data[2],']';
echo '[',$data[3],']';
echo '[',$data[-1],']';
echo '[',$data[-2],']';

echo "<pre>";
echo htmlspecialchars(implode('',file($_SERVER['SCRIPT_FILENAME'])));
echo "</pre>";
phpinfo();
?>
</body></html>

PHP Logo
PHP Version 4.1.2

Actual result:
--------------
[b][b][b][2][3][][][]

<html><body>
<?php
/*
why does this script print the first character of
$data['foo'] if called with the url parameter
data set to something, e.g. .../test.php?data=123
A bug?

*/

$data['dummy']='nothing';
$data['foo']='bar';
echo '[',$data[null],']';
echo '[',$data[''],']';
echo '[',$data[0],']';
echo '[',$data[1],']';
echo '[',$data[2],']';
echo '[',$data[3],']';
echo '[',$data[-1],']';
echo '[',$data[-2],']';

echo "<pre>";
echo htmlspecialchars(implode('',file($_SERVER['SCRIPT_FILENAME'])));
echo "</pre>";
phpinfo();
?>
</body></html>

PHP Logo
PHP Version 4.1.2

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-25 15:16 UTC] sniper@php.net
Install 4.3.4, set register_globals=off and error_reporting=E_ALL in your php.ini..

And RTFM.

 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Jan 24 16:01:24 2020 UTC