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 for heap access violation #513

Merged
merged 5 commits into from
Aug 30, 2022
Merged

Conversation

TwistedTwigleg
Copy link
Contributor

@TwistedTwigleg TwistedTwigleg commented Aug 29, 2022

Description of changes:

Fixes a heap access violation found when implementing AppVerifier into the C++ V2 SDK CI. AppVerifier finds the issue at the end of running a sample and, according to the logs provided by AppVerifier, it is caused by an access violation caused by calling CertFreeCertificateContext in windows/secure_channel_tls_handler.c in the s_secure_channel_ctx_destroy function.

The issue seems to be that CryptDestroyKey frees the private key certificate context and so then when CertFreeCertificateContext is called to free the private key certificate context further down, it leads to the access violation since it is already free. Freeing the private certificate key store first, before the private key, causes the same issue when trying to free the private key.

The fix implemented is to check if the private key was loaded from the private certificate store and, if it was, not delete the certificate store on shutdown.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@TwistedTwigleg TwistedTwigleg changed the title Fix for heap access violation recently found by AppVerifier Fix for heap access violation Aug 29, 2022
@TwistedTwigleg
Copy link
Contributor Author

Thanks! Merging into main...

@TwistedTwigleg TwistedTwigleg merged commit b76fd20 into main Aug 30, 2022
@TwistedTwigleg TwistedTwigleg deleted the WindowsAppVerifierHeapFix branch August 30, 2022 18:58
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

2 participants