-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed indirect modification of magic ArrayAccess method arguments
- Loading branch information
Showing
9 changed files
with
198 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--TEST-- | ||
Bug #75420.10 (Indirect modification of magic method argument) | ||
--FILE-- | ||
<?php | ||
class Test implements ArrayAccess { | ||
public function offsetExists($x) { $GLOBALS["name"] = 24; return true; } | ||
public function offsetGet($x) { var_dump($x); return 42; } | ||
public function offsetSet($x, $y) { } | ||
public function offsetUnset($x) { } | ||
} | ||
|
||
$obj = new Test; | ||
$name = "foo"; | ||
$name = str_repeat($name, 2); | ||
var_dump($obj[$name] ?? 12); | ||
var_dump($name); | ||
?> | ||
--EXPECT-- | ||
string(6) "foofoo" | ||
int(42) | ||
int(24) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--TEST-- | ||
Bug #75420.11 (Indirect modification of magic method argument) | ||
--FILE-- | ||
<?php | ||
class Test implements ArrayAccess { | ||
public function offsetExists($x) { $GLOBALS["name"] = 24; return true; } | ||
public function offsetGet($x) { var_dump($x); return 42; } | ||
public function offsetSet($x, $y) { } | ||
public function offsetUnset($x) { } | ||
} | ||
|
||
$obj = new Test; | ||
$name = "foo"; | ||
var_dump(empty($obj[$name])); | ||
var_dump($name); | ||
?> | ||
--EXPECT-- | ||
string(3) "foo" | ||
bool(false) | ||
int(24) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--TEST-- | ||
Bug #75420.12 (Indirect modification of magic method argument) | ||
--FILE-- | ||
<?php | ||
class Test implements ArrayAccess { | ||
public function offsetExists($x) { $GLOBALS["name"] = 24; return true; } | ||
public function offsetGet($x) { var_dump($x); return 42; } | ||
public function offsetSet($x, $y) { } | ||
public function offsetUnset($x) { } | ||
} | ||
|
||
$obj = new Test; | ||
$name = "foo"; | ||
$name = str_repeat($name, 2); | ||
var_dump(empty($obj[$name])); | ||
var_dump($name); | ||
?> | ||
--EXPECT-- | ||
string(6) "foofoo" | ||
bool(false) | ||
int(24) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--TEST-- | ||
Bug #75420.13 (Indirect modification of magic method argument) | ||
--FILE-- | ||
<?php | ||
class Test implements ArrayAccess { | ||
public function offsetExists($x) { $GLOBALS["obj"] = 24; return true; } | ||
public function offsetGet($x) { var_dump($x); return 42; } | ||
public function offsetSet($x, $y) { } | ||
public function offsetUnset($x) { } | ||
} | ||
|
||
$obj = new Test; | ||
$name = "foo"; | ||
var_dump($obj[$name] ?? 12); | ||
var_dump($obj); | ||
?> | ||
--EXPECT-- | ||
string(3) "foo" | ||
int(42) | ||
int(24) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--TEST-- | ||
Bug #75420.14 (Indirect modification of magic method argument) | ||
--FILE-- | ||
<?php | ||
class Test implements ArrayAccess { | ||
public function offsetExists($x) { $GLOBALS["obj"] = 24; return true; } | ||
public function offsetGet($x) { var_dump($x); return 42; } | ||
public function offsetSet($x, $y) { } | ||
public function offsetUnset($x) { } | ||
} | ||
|
||
$obj = new Test; | ||
$name = "foo"; | ||
var_dump(empty($obj[$name])); | ||
var_dump($obj); | ||
?> | ||
--EXPECT-- | ||
string(3) "foo" | ||
bool(false) | ||
int(24) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--TEST-- | ||
Bug #75420.15 (Indirect modification of magic method argument) | ||
--FILE-- | ||
<?php | ||
class Test implements ArrayAccess { | ||
public function offsetExists($x) { } | ||
public function offsetGet($x) { } | ||
public function offsetSet($x, $y) { $GLOBALS["name"] = 24; var_dump($x); } | ||
public function offsetUnset($x) { } | ||
} | ||
|
||
$obj = new Test; | ||
$name = "foo"; | ||
$name = str_repeat($name, 2); | ||
$obj[$name] = 1; | ||
var_dump($name); | ||
?> | ||
--EXPECT-- | ||
string(6) "foofoo" | ||
int(24) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--TEST-- | ||
Bug #75420.16 (Indirect modification of magic method argument) | ||
--FILE-- | ||
<?php | ||
class Test implements ArrayAccess { | ||
public function offsetExists($x) { } | ||
public function offsetGet($x) { } | ||
public function offsetSet($x, $y) { $GLOBALS["obj"] = 24; var_dump($this); } | ||
public function offsetUnset($x) { } | ||
} | ||
|
||
$obj = new Test; | ||
$name = "foo"; | ||
$obj[$name] = 1; | ||
var_dump($obj); | ||
?> | ||
--EXPECT-- | ||
object(Test)#1 (0) { | ||
} | ||
int(24) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--TEST-- | ||
Bug #75420.9 (Indirect modification of magic method argument) | ||
--FILE-- | ||
<?php | ||
class Test implements ArrayAccess { | ||
public function offsetExists($x) { $GLOBALS["name"] = 24; return true; } | ||
public function offsetGet($x) { var_dump($x); return 42; } | ||
public function offsetSet($x, $y) { } | ||
public function offsetUnset($x) { } | ||
} | ||
|
||
$obj = new Test; | ||
$name = "foo"; | ||
var_dump($obj[$name] ?? 12); | ||
var_dump($name); | ||
?> | ||
--EXPECT-- | ||
string(3) "foo" | ||
int(42) | ||
int(24) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters