Testability pattern
83_array_variable_key
Problem statement
The php code for instance 2 and instance 3 is the same.
<?php
$a = "ttt";
$b = $_GET["p1"];
$c = $_GET["p2"];
$x = array(1,2,$a=>$b);
echo $x[$c];
Proposed changes
One possiblity for changing the code of instance 3 I came up with, was this:
<?php
$b = $_GET["p1"];
$c = $_GET["p2"]; // source
$x = array(1,2,$b=>$c);
echo $x[$b]; // sink
The key and the value in x are now user controlled.
This is of course only one possibility.
Other
Do you have any other ideas? Or is it more useful to delete that instance?
Testability pattern
83_array_variable_key
Problem statement
The php code for instance 2 and instance 3 is the same.
Proposed changes
One possiblity for changing the code of instance 3 I came up with, was this:
The key and the value in
xare now user controlled.This is of course only one possibility.
Other
Do you have any other ideas? Or is it more useful to delete that instance?