Skip to content

Commit

Permalink
* mod_ssl: fix small memory leak in ssl_init_server_certs when ECDH i…
Browse files Browse the repository at this point in the history
…s used.

SSL_CTX_set_tmp_ecdh increases reference count, so we have to call EC_KEY_free,
otherwise eckey will not be freed.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1666363 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Jan Kaluža committed Mar 13, 2015
1 parent 23bc41f commit 35ae2e2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions modules/ssl/ssl_engine_init.c
Expand Up @@ -982,7 +982,7 @@ static apr_status_t ssl_init_server_certs(server_rec *s,
#ifdef HAVE_ECC
EC_GROUP *ecparams;
int nid;
EC_KEY *eckey;
EC_KEY *eckey = NULL;
#endif
#ifndef HAVE_SSL_CONF_CMD
SSL *ssl;
Expand Down Expand Up @@ -1151,10 +1151,11 @@ static apr_status_t ssl_init_server_certs(server_rec *s,
#if defined(SSL_CTX_set_ecdh_auto)
SSL_CTX_set_ecdh_auto(mctx->ssl_ctx, 1);
#else
SSL_CTX_set_tmp_ecdh(mctx->ssl_ctx,
EC_KEY_new_by_curve_name(NID_X9_62_prime256v1));
eckey = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
SSL_CTX_set_tmp_ecdh(mctx->ssl_ctx, eckey);
#endif
}
EC_KEY_free(eckey);
#endif

return APR_SUCCESS;
Expand Down

0 comments on commit 35ae2e2

Please sign in to comment.