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
Invalid free of CG(interned_empty_string) #1060
Conversation
On failure php_escape_html_entities returns STR_EMPTY_ALLOC which is an alias of CG(interned_empty_string) if interned strings are enabled. Make sure we don't free this.
@manualm, could you please provide a reproduce case for this? Or even better, add a phpt? Thanks. |
The bug report includes one-liners to trigger the bug. Every invalid free has its own line. However there's no phpt because you can't easily check the content of CG(interned_empty_string) from php. |
@manuelm, yeah, but phpt is what we usually do when referencing some erroneous function call. Also that ensures the functionality is correct in future. Why I ask for this again is because i don't reproduce invalid reads you mention in the ticket, valgrind 3.8.1 . Is there something special needed, maybe some ini options? I'd still ask for adding a phpt, so one can run it with and without your patch to tell the diff. Thanks. |
For the first-listed invalid free you need to enable the html_errors ini flag. The others should be traceable out of the box. |
@weltling Do you still want me to provide a phpt-file with the calls included? |
this should also exists in 5.5, but not master |
Sure about this? imho interned_empty_string has been introduced in PHP-5.6 see https://github.com/php/php-src/blob/PHP-5.5/Zend/zend.h#L676 |
@manuelm ok, behavior confirmed. Despite it's only reproducible with valgrind, I'd say a phpt would still be useful because "make test" can be done with valgrind enabled and then it'd be catchable. The patch should go in anyway, but it would be really nice to have some phpt as well. @laruence looks like i cant repro it in 5.5 and master, but 5.6 ... probably it's 5.6 only Checking a bit more yet. Thanks. |
@manuelm you are right. I remembered it wrongly |
Tests added. I've split them among the various extensions. Hope that's ok. |
@manuelm thanks for the tests, checking all together to merge tomorrow. So if you're adding some more stuff till then, it's fine. Thanks. |
On failure php_escape_html_entities returns STR_EMPTY_ALLOC which is an
alias of CG(interned_empty_string) if interned strings are enabled.
Make sure we don't free this.
Fixes #68996