forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix out of bound writes to SafeArray data
Converting PHP arrays to Variants originally supported almost arbitrary numeric arrays, possibly filling gaps with NULL values. This is broken as of PHP 7.0.0[1] so that the SafeArray only has as many elements as the PHP array. Thus, unless the array is a list, some elements may be written outside of the SafeArray data. To avoid breaking userland code after that long time, we do not restore the original behavior, but instead only suppress the erroneous writes. To avoid the need to split the regression test for 32bit and 64bit Windows, we suppress the "max number 4294967295 of elements in safe array exceeded" warning, which only occurs for 64bit versions. [1] <php@c865472> Closes phpGH-16309.
- Loading branch information
Showing
3 changed files
with
37 additions
and
3 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
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
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,30 @@ | ||
--TEST-- | ||
Testing variant arrays | ||
--EXTENSIONS-- | ||
com_dotnet | ||
--FILE-- | ||
<?php | ||
$arrays = [ | ||
"order" => [2 => 1, 1 => 2, 0 => 3], | ||
"off" => [2 => 1, 1 => 2, 3], | ||
"negative" => [-1 => 42], | ||
]; | ||
foreach ($arrays as $desc => $array) { | ||
echo "-- $desc --\n"; | ||
$v = new variant($array); | ||
foreach ($v as $val) { | ||
var_dump($val); | ||
} | ||
} | ||
?> | ||
--EXPECTF-- | ||
-- order -- | ||
int(3) | ||
int(2) | ||
int(1) | ||
-- off -- | ||
NULL | ||
int(2) | ||
int(1) | ||
-- negative -- | ||
%ANULL |