Skip to content

Commit

Permalink
md_crypt: Fix potential memory leak with openssl < 3.
Browse files Browse the repository at this point in the history
EVP_PKEY_get1_RSA()'s returned value should be EVP_PKEY_free()d, but
we can use EVP_PKEY_get0_RSA() here.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1913616 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
ylavic committed Nov 6, 2023
1 parent f81b273 commit a441f0d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/md/md_crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ static const char *bn64(const BIGNUM *b, apr_pool_t *p)
const char *md_pkey_get_rsa_e64(md_pkey_t *pkey, apr_pool_t *p)
{
#if OPENSSL_VERSION_NUMBER < 0x30000000L
RSA *rsa = EVP_PKEY_get1_RSA(pkey->pkey);
const RSA *rsa = EVP_PKEY_get0_RSA(pkey->pkey);
if (rsa) {
const BIGNUM *e;
RSA_get0_key(rsa, NULL, &e, NULL);
Expand All @@ -1012,7 +1012,7 @@ const char *md_pkey_get_rsa_e64(md_pkey_t *pkey, apr_pool_t *p)
const char *md_pkey_get_rsa_n64(md_pkey_t *pkey, apr_pool_t *p)
{
#if OPENSSL_VERSION_NUMBER < 0x30000000L
RSA *rsa = EVP_PKEY_get1_RSA(pkey->pkey);
const RSA *rsa = EVP_PKEY_get0_RSA(pkey->pkey);
if (rsa) {
const BIGNUM *n;
RSA_get0_key(rsa, &n, NULL, NULL);
Expand Down

0 comments on commit a441f0d

Please sign in to comment.