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

lftp_ssl: deinitialize the lftp_ssl_openssl_instance #723

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tabraham
Copy link

If the instance isn't deinitialized prior to exit, the OPENSSL_cleanup exit handler may run before the
lftp_ssl_openssl_instance destructor on exit resulting in a segfault.

This fixes a null deref on exit.

Fixes #716

If the instance isn't deinitialized prior to exit, the
OPENSSL_cleanup exit handler may run before the
lftp_ssl_openssl_instance destructor on exit resulting
in a segfault.

This fixes a null deref on exit.

Fixes lavv17#716
@@ -863,6 +863,7 @@ lftp_ssl_openssl::~lftp_ssl_openssl()
{
SSL_free(ssl);
ssl=0;
global_deinit();
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think we need to deinit the whole openssl every time a connection is closed. A better solution is needed.

Copy link
Author

Choose a reason for hiding this comment

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

It just needs to be done before exit. Can you suggest a better location?

Copy link
Owner

Choose a reason for hiding this comment

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

I think OpenSSL clean up can be skipped altogether, it is not strictly required.

Copy link
Author

Choose a reason for hiding this comment

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

It may not be strictly required, but the documentation does not suggest it is optional.

From
https://www.openssl.org/docs/man1.1.1/man3/OPENSSL_init_crypto.html

OPENSSL_INIT_NO_ATEXIT

By default OpenSSL will attempt to clean itself up when the process exits via an "atexit" handler. Using this option suppresses that behaviour. This means that the application will have to clean up OpenSSL explicitly using OPENSSL_cleanup().

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.

lftp segfault on exit
2 participants