Skip to content

Gh16359 #16362

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 1 commit into from
Closed

Gh16359 #16362

wants to merge 1 commit into from

Conversation

devnexen
Copy link
Member

No description provided.

@devnexen devnexen force-pushed the gh16359 branch 2 times, most recently from 608e339 to 66646b5 Compare October 11, 2024 06:25
@devnexen devnexen marked this pull request as ready for review October 11, 2024 06:25
@devnexen devnexen requested review from dstogov and adoy as code owners October 11, 2024 06:25
Zend/zend_API.h Outdated
@@ -843,6 +843,12 @@ static zend_always_inline void zend_call_known_fcc(
const zend_fcall_info_cache *fcc, zval *retval_ptr, uint32_t param_count, zval *params, HashTable *named_params)
{
zend_function *func = fcc->function_handler;
if (UNEXPECTED(!func)) {
Copy link
Member

Choose a reason for hiding this comment

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

This should be handled in curl, and not call zend_call_known_fcc instead. I don't really know curl, but it looks like you might want to unset the PHP_CURL_USER flag when it's set to null.

Copy link
Member

@dstogov dstogov left a comment

Choose a reason for hiding this comment

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

zend_call_known_fcc must not be used without fcc->function_handler.
I agree with @iluuu1994. This should be fixed in the extension code.

@devnexen
Copy link
Member Author

oki doki fair enough, going to update.

@@ -1634,7 +1634,10 @@ static bool php_curl_set_callable_handler(zend_fcall_info_cache *const handler_f
#define HANDLE_CURL_OPTION_CALLABLE_PHP_CURL_USER(curl_ptr, constant_no_function, handler_type) \
case constant_no_function##FUNCTION: { \
bool result = php_curl_set_callable_handler(&curl_ptr->handlers.handler_type->fcc, zvalue, is_array_config, #constant_no_function "FUNCTION"); \
if (!result) { \
if (!result \
|| (curl_ptr->handlers.read && !curl_ptr->handlers.read->fcc.function_handler) \
Copy link
Member

Choose a reason for hiding this comment

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

There's ZEND_FCC_INITIALIZED, you should probably use that. I'm also not sure setting it to null is considered unsuccessful.

Comment on lines 1637 to 1640
if (!result \
|| (curl_ptr->handlers.read && !curl_ptr->handlers.read->fcc.function_handler) \
|| (curl_ptr->handlers.write && !curl_ptr->handlers.write->fcc.function_handler) \
|| (curl_ptr->handlers.write_header && !curl_ptr->handlers.write_header->fcc.function_handler)) { \
Copy link
Member

Choose a reason for hiding this comment

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

This looks weird.
You probably have to check just if (!result) or
if (!result || !curl_ptr->handlers.handler_type->fcc.function_handler).

Copy link
Member Author

Choose a reason for hiding this comment

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

yes I just did locally I realised later..

@devnexen devnexen marked this pull request as draft October 11, 2024 07:20
case constant_no_function##FUNCTION: { \
bool result = php_curl_set_callable_handler(&curl_ptr->handlers.handler_type->fcc, zvalue, is_array_config, #constant_no_function "FUNCTION"); \
if (!result) { \
return FAILURE; \
} \
if (!curl_ptr->handlers.handler_type) { \
Copy link
Member

Choose a reason for hiding this comment

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

It doesn't seem like this condition can be true? Otherwise we'd have a null pointer violation above.

} \
if (!ZEND_FCC_INITIALIZED(curl_ptr->handlers.handler_type->fcc)) { \
curl_ptr->handlers.handler_type->method = default_method; \
return FAILURE; \
Copy link
Member

@iluuu1994 iluuu1994 Oct 11, 2024

Choose a reason for hiding this comment

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

This should return SUCCESS. Setting options to null is allowed from what I understand. If you return FAILURE here, you'll stop updating the other options in curl_setopt_array, apart from also indicating an error in curl_setopt.

@devnexen devnexen marked this pull request as ready for review October 11, 2024 07:44
Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

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

Thank you! This looks correct to me now. Maybe @Girgias can have a look as she was the one refactoring this code last.

@devnexen
Copy link
Member Author

would it be good to add an (zend) assert into the FCC part though ?

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

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

Arf, I thought that we always had an FCC in those cases.

Thanks for fixing this!

@devnexen devnexen closed this in 42f8776 Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants