-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix bug #79836: Segfault in concat_function #10049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
23ffbd9
Fix #97836: Segfault in concat_function
nielsdos 8ab19f7
Add regression tests for bug #79836
nielsdos b9beac5
Add regression test for bug #81705
nielsdos 4434e87
Add an additional test for concat_function for interned strings
nielsdos 73526db
Add an additional test for concat_function for non-interned strings
nielsdos 41d2524
Fix after rebase
nielsdos c6a6189
Simplify and comment
nielsdos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,18 @@ | ||
--TEST-- | ||
Bug #79836 (Segfault in concat_function) | ||
--INI-- | ||
opcache.optimization_level = 0x7FFEBFFF & ~0x400 | ||
--FILE-- | ||
<?php | ||
$counter = 0; | ||
ob_start(function ($buffer) use (&$c, &$counter) { | ||
$c = 0; | ||
++$counter; | ||
}, 1); | ||
$c .= []; | ||
$c .= []; | ||
ob_end_clean(); | ||
echo $counter . "\n"; | ||
?> | ||
--EXPECT-- | ||
3 |
This file contains hidden or 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,18 @@ | ||
--TEST-- | ||
Bug #79836 (Segfault in concat_function) | ||
--INI-- | ||
opcache.optimization_level = 0x7FFEBFFF & ~0x400 | ||
--FILE-- | ||
<?php | ||
$x = 'non-empty'; | ||
ob_start(function () use (&$c) { | ||
$c = 0; | ||
}, 1); | ||
$c = []; | ||
$x = $c . $x; | ||
$x = $c . $x; | ||
ob_end_clean(); | ||
echo "Done\n"; | ||
?> | ||
--EXPECT-- | ||
Done |
This file contains hidden or 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,25 @@ | ||
--TEST-- | ||
Bug #79836 (Segfault in concat_function) | ||
--FILE-- | ||
<?php | ||
$c = str_repeat("abcd", 10); | ||
|
||
ob_start(function () use (&$c) { | ||
$c = 0; | ||
}, 1); | ||
|
||
class X { | ||
function __toString() { | ||
echo "a"; | ||
return "abc"; | ||
} | ||
} | ||
|
||
$xxx = new X; | ||
|
||
$x = $c . $xxx; | ||
ob_end_clean(); | ||
echo $x . "\n"; | ||
?> | ||
--EXPECT-- | ||
abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabc |
This file contains hidden or 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,19 @@ | ||
--TEST-- | ||
Bug #81705 (type confusion/UAF on set_error_handler with concat operation) | ||
--FILE-- | ||
<?php | ||
|
||
$arr = [0]; | ||
$my_var = str_repeat("a", 1); | ||
set_error_handler( | ||
function() use(&$my_var) { | ||
echo("error\n"); | ||
$my_var = 0x123; | ||
} | ||
); | ||
$my_var .= $GLOBALS["arr"]; | ||
var_dump($my_var); | ||
?> | ||
--EXPECT-- | ||
error | ||
string(6) "aArray" |
21 changes: 21 additions & 0 deletions
21
Zend/tests/class_toString_concat_non_interned_with_itself.phpt
This file contains hidden or 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-- | ||
Test concatenating a class instance that has __toString with itself that uses a non-interned string | ||
--FILE-- | ||
<?php | ||
$global_non_interned_string = str_repeat("a", 3); | ||
|
||
class Test { | ||
public function __toString() { | ||
global $global_non_interned_string; | ||
return $global_non_interned_string; | ||
} | ||
} | ||
|
||
$test1 = new Test; | ||
$test2 = new Test; | ||
$test1 .= $test2; | ||
|
||
echo $test1 . "\n"; | ||
?> | ||
--EXPECT-- | ||
aaaaaa |
This file contains hidden or 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,16 @@ | ||
--TEST-- | ||
Test concatenating a class instance that has __toString with itself | ||
--FILE-- | ||
<?php | ||
class Tmp { | ||
public function __toString() { | ||
return "abc"; | ||
} | ||
} | ||
|
||
$tmp = new Tmp; | ||
$tmp .= $tmp; | ||
echo $tmp . "\n"; | ||
?> | ||
--EXPECT-- | ||
abcabc |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.