-
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.
Fix use after free when rebinding __call closure
We would end up freeing the function name twice here, once for the original closure, and once for the rebound one. Rather than further special casing the zend_closure_call_magic case, always addref the function_name for internal functions, the same we do for userland functions. To compensate, we need to release the original function name when creating from callable or call frame. Fixes oss-fuzz #37695.
- Loading branch information
Showing
2 changed files
with
30 additions
and
1 deletion.
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,20 @@ | ||
--TEST-- | ||
Calling bindTo() on __call() closure | ||
--FILE-- | ||
<?php | ||
|
||
class Foo { | ||
function __call($name, $args) { | ||
echo "__call($name)\n"; | ||
} | ||
} | ||
|
||
$foo = new Foo; | ||
$name = "foo"; | ||
Closure::fromCallable([$foo, $name . "bar"])->bindTo(new Foo)(); | ||
$foo->{$name . "bar"}(...)->bindTo(new Foo)(); | ||
|
||
?> | ||
--EXPECT-- | ||
__call(foobar) | ||
__call(foobar) |
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