Skip to content

Fix memory leak in openssl fips modes - #7064

Merged
ethomson merged 1 commit into
mainfrom
unknown repository
Jun 5, 2025
Merged

Fix memory leak in openssl fips modes#7064
ethomson merged 1 commit into
mainfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Apr 11, 2025

Copy link
Copy Markdown

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

ethomson commented Jun 5, 2025

Copy link
Copy Markdown
Member

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