Skip to content
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

Fix memory leak with passing in TLS context config from php application #50

Merged
merged 2 commits into from
Mar 20, 2024

Conversation

drewfrezell-intuit
Copy link

Description of changes:

createAndSetTLSContext improperly handled zend_string reference counting and didn't free memory after the context was set. Fix by simplifying the hash loop by immediately calling php_set_tls_context_configurations with the zkey and zvalue. We then let the conversion of the zvalue type happen for the specific config setting. Also, add helper method to strdup values using the proper zval_string and release methods.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@sodabrew
Copy link
Contributor

If this bug is present upstream, would you submit the PR to php-memcached-dev/php-memcached

@drewfrezell-intuit
Copy link
Author

This is specific to the AWS extension that adds TLS support to Elasticache:Memcache.

Copy link
Contributor

@barshaul barshaul left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

ok = 0;
}
return ok;
}

static void php_free_tls_context_configurations(memcached_ssl_context_config *config) {
if (config->cert_file) {
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: indentation is off

@barshaul barshaul merged commit d1b6afd into awslabs:php8.x Mar 20, 2024
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.

None yet

3 participants