Skip to content

Fix memory leak in openssl fips modes #7064

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

Merged
merged 1 commit into from
Jun 5, 2025

Conversation

ghost
Copy link

@ghost ghost commented Apr 11, 2025

Version 1.9.0 introduced a memory leak when using the new FIPS-compliant mode (-DUSE_SHA256=OpenSSL-FIPS).

The culprit turned out to be the ctx->c = NULL; line added to git_hash_sha256_final function, which too hastily cleans up a pointer. Because of that, the cleanup function call to EVP_MD_CTX_free(nullptr) doesn't have any effect and the memory is never freed.

The same applies to SHA1 fips mode.

@ghost ghost changed the title Fixed memory leak in openssl fips modes Fix memory leak in openssl fips modes Apr 11, 2025
@ethomson
Copy link
Member

ethomson commented Jun 5, 2025

Good catch. Thanks!

@ethomson ethomson merged commit 29e4e19 into libgit2:main Jun 5, 2025
@ghost ghost deleted the openssl-fips-memory-leak branch June 5, 2025 11:52
@ethomson ethomson added the bug label Jun 6, 2025
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.

1 participant