summaryrefslogtreecommitdiffstats
path: root/crypto/ecdh
diff options
context:
space:
mode:
authorBernd Edlinger <bernd.edlinger@hotmail.de>2017-07-01 22:18:10 +0200
committerBernd Edlinger <bernd.edlinger@hotmail.de>2017-07-02 07:56:27 +0200
commit0cfb422656b0807b23f63fccea0a12ab2bddbbb1 (patch)
treef8e0044f986916366759f744642996369f7ac098 /crypto/ecdh
parent282c1321962e7ed1714c7d59495c60affce806db (diff)
Fix a memory leak in ecdh/ecdsa_check.
Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3825)
Diffstat (limited to 'crypto/ecdh')
-rw-r--r--crypto/ecdh/ech_lib.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/crypto/ecdh/ech_lib.c b/crypto/ecdh/ech_lib.c
index cbc21d1a27..9cc22582e4 100644
--- a/crypto/ecdh/ech_lib.c
+++ b/crypto/ecdh/ech_lib.c
@@ -225,9 +225,16 @@ ECDH_DATA *ecdh_check(EC_KEY *key)
*/
ecdh_data_free(ecdh_data);
ecdh_data = (ECDH_DATA *)data;
+ } else if (EC_KEY_get_key_method_data(key, ecdh_data_dup,
+ ecdh_data_free,
+ ecdh_data_free) != ecdh_data) {
+ /* Or an out of memory error in EC_KEY_insert_key_method_data. */
+ ecdh_data_free(ecdh_data);
+ return NULL;
}
- } else
+ } else {
ecdh_data = (ECDH_DATA *)data;
+ }
#ifdef OPENSSL_FIPS
if (FIPS_mode() && !(ecdh_data->flags & ECDH_FLAG_FIPS_METHOD)
&& !(EC_KEY_get_flags(key) & EC_FLAG_NON_FIPS_ALLOW)) {