Skip to content

Declare ext/soap properties #6759

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 4 commits into from
Closed

Conversation

kocsismate
Copy link
Member

@kocsismate kocsismate commented Mar 7, 2021

No description provided.

@kocsismate kocsismate force-pushed the soap-properties branch 2 times, most recently from 7dd769c to 677d661 Compare March 8, 2021 13:14
Copy link
Member Author

@kocsismate kocsismate left a comment

Choose a reason for hiding this comment

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

Now, only 2 tests fail, but I am out of ideas how to solve them. :/


if ((ztype = zend_hash_str_find_deref(ht, "enc_type", sizeof("enc_type")-1)) == NULL ||
Z_TYPE_P(ztype) != IS_LONG) {
ztype = zend_read_property(soap_var_class_entry, Z_OBJ_P(data), "enc_type", sizeof("enc_type")-1, 1, &rv);
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know whether it's better to explicitly specify the class entry or I should just use Z_OBJCE_P(data) in all the zend_read_property() calls. Also, currently I pass 1 to the silent parameter, but probably it shouldn't be the case?

Copy link
Member

Choose a reason for hiding this comment

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

As these are public properties, it doesn't really make a difference. But generally, this is the scope from which you access the property, so explicitly passing soap_var_class_entry is semantically correct.

Note that read_property doesn't return NULL, an undefined property is &EG(uninitialized_zval). I think using silent mode and explicitly reporting an error is okay in this file, because it uses some super broken error handling -- passing through the normal exception would be ideal, but it's probably not easily possible.

I suspect that you also need to add a ZVAL_DEREF here, don't think read_property does that by itself.

Copy link
Member

Choose a reason for hiding this comment

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

The fact that &EG(uninitialized_zval) is returned means that the type is effectively null. So if you perform some type check, you can just drop the NULL pointer check entirely.

It may make sense to add a read_property_deref helper as this is probably going to be a common pattern for this type of code.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the hints! I like the idea of adding the helper. And I'll try to fix these issues the following days

Copy link
Member Author

@kocsismate kocsismate Apr 17, 2021

Choose a reason for hiding this comment

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

My newest commit (1c75f6d) addresses the review comments, so now only one test fails. Although error handling of property reading is still broken. :(

@kocsismate kocsismate force-pushed the soap-properties branch 4 times, most recently from c32892b to 1c75f6d Compare April 17, 2021 21:44
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.

Something that occurred to me is that strictly speaking, these uses of zend_read_property aren't safe, due to how the rv parameter is treated. Say, if a nefarious user were to extend one of those classes, unset the declared properties and add a __get() handler, then rv would end up being used, and would leak values. Of course, the same mistake is made in many other places :/ It's not easy to use the current API correctly, as it's a thin wrapper around the low-level handler.

/** @var string|null */
public $faultcode;

/** @var string|null */
Copy link
Member

Choose a reason for hiding this comment

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

Why are these commented?

Copy link
Member Author

Choose a reason for hiding this comment

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

As far as I remember I got segfaults when I uncommented them, and I unfortunately didn't manage to find the root cause. I can retry it sometime soon.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not easy to use the current API correctly, as it's a thin wrapper around the low-level handler.

Do you have any idea (like a new API) in mind? Or we should rather accept the fact that there are problems with zend_read_property()?

@ramsey ramsey added the Feature label May 8, 2021
@kocsismate
Copy link
Member Author

Closing this PR because soap properties has recently became declared.

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

Successfully merging this pull request may close these issues.

3 participants