-
Notifications
You must be signed in to change notification settings - Fork 8k
Fix oss-fuzz-61469: Undef dynamic property in ++/-- unset in error handler #12011
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
Conversation
|
I'll need to look into this in detail, but when I checked the oss-fuzz report this was an issue for ++, -- (pre and post), += and -= alike. |
|
Indeed, I was confused why the pre increment change also worked for post increment. But it seems there is a compile time optimization to rewrite a post increment to a pre one if the return value is not used. (Or a for loop might also leave the post increment) Confirmed and fixed the binop case |
|
It looks like the problem is already fixed by a3a3964 |
Post increments are converted to pre increments if no return value is used. Ditto for decrement
I'm not sure this is totally fixed, as if I revert the VM changes the following test: --TEST--
OSS Fuzz #61469: Undef variable in ++/-- for dynamic property that is unset in error handler
--FILE--
<?php
class C {
function errorHandle() {
unset($this->a);
}
}
$c = new C;
set_error_handler([$c,'errorHandle']);
$c->a += 5;
var_dump($c->a);
?>Results in dumping |
I'm really not sure this is the expected output
2ff900e to
d037398
Compare
dstogov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved.
Please, also take a look into oss-fuzz 61865, that looks similar
<?php
class C {
public $a;
function errorHandler() {
unset($this->a);
}
}
$c=new C;
set_error_handler([$c,'errorHandler']);
array($y);
(++$c->a);
So this issue is caused by the undefined property warning generated in the standard
get_property_ptr_ptrobject handler.I suppose this might have been a pre-existing issue if an extension
get_property_ptr_ptrhandler did something to the ZVAL but considering what needs to be done this seems unlikely.The easiest solution is to just consider the value as
nulland move forward with it.@dstogov is this approach a good idea or not?