Skip to content

Fix segfault on PHP 7.3 #3708

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
wants to merge 3 commits into from
Closed

Conversation

paragonie-scott
Copy link
Contributor

@paragonie-scott paragonie-scott commented Dec 14, 2018

@@ -387,7 +387,8 @@ static void sodium_remove_param_values_from_backtrace(zend_object *obj) {
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(trace), frame) {
if (Z_TYPE_P(frame) == IS_ARRAY) {
zval *args = zend_hash_str_find(Z_ARRVAL_P(frame), "args", sizeof("args")-1);
if (args && Z_TYPE_P(frame) == IS_ARRAY) {
if (args != NULL && Z_TYPE_P(args) == IS_ARRAY &&
Z_REFCOUNTED_P(args) && Z_REFCOUNT_P(args) == 1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the intention here is to hide arguments, this check would kinda defeat the point in the cases where it triggers. As an alternative, I'd suggest doing something like

zval *args = zend_hash_str_find(Z_ARRVAL_P(frame), "args", sizeof("args")-1);
zval_ptr_dtor(args);
ZVAL_EMPTY_ARRAY(args);

in order to overwrite with an empty array, without corrupting the original one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nikic
Copy link
Member

nikic commented Dec 14, 2018

Could you please also add a test file, to avoid regressing this in the future?

@paragonie-scott
Copy link
Contributor Author

Yep! :)

@paragonie-scott
Copy link
Contributor Author

I have no idea what's going on with the Windows build here, but it seems wholly unrelated to the libsodium change.

Copy link
Member

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor failure is intermittent.

@cmb69
Copy link
Member

cmb69 commented Dec 16, 2018

Thanks! Applied as e0e08d3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants