diff options
author | Tobias Heider <tobhe@cvs.openbsd.org> | 2022-11-10 12:37:01 +0000 |
---|---|---|
committer | Tobias Heider <tobhe@cvs.openbsd.org> | 2022-11-10 12:37:01 +0000 |
commit | 9827196e6b93f524c17b3657c5b76ea3b14d1f05 (patch) | |
tree | 709f62d81cfdd8a9d688979a138af9f20f52079e /lib/libcrypto/ec | |
parent | 4df31ff80f21b8df06fab2b815e6a77ba968a899 (diff) |
Fix a few more leaks in *_print() functions.
ok jsing@
Diffstat (limited to 'lib/libcrypto/ec')
-rw-r--r-- | lib/libcrypto/ec/eck_prn.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/lib/libcrypto/ec/eck_prn.c b/lib/libcrypto/ec/eck_prn.c index c2fd2ebc85b..058ae57de5b 100644 --- a/lib/libcrypto/ec/eck_prn.c +++ b/lib/libcrypto/ec/eck_prn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eck_prn.c,v 1.17 2021/04/20 17:12:43 tb Exp $ */ +/* $OpenBSD: eck_prn.c,v 1.18 2022/11/10 12:37:00 tobhe Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -121,11 +121,16 @@ int EC_KEY_print(BIO * bp, const EC_KEY * x, int off) { EVP_PKEY *pk; - int ret; - pk = EVP_PKEY_new(); - if (!pk || !EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) - return 0; + int ret = 0; + + if ((pk = EVP_PKEY_new()) == NULL) + goto err; + + if (!EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) + goto err; + ret = EVP_PKEY_print_private(bp, pk, off, NULL); + err: EVP_PKEY_free(pk); return ret; } @@ -134,11 +139,16 @@ int ECParameters_print(BIO * bp, const EC_KEY * x) { EVP_PKEY *pk; - int ret; - pk = EVP_PKEY_new(); - if (!pk || !EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) - return 0; + int ret = 0; + + if ((pk = EVP_PKEY_new()) == NULL) + goto err; + + if (!EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) + goto err; + ret = EVP_PKEY_print_params(bp, pk, 4, NULL); + err: EVP_PKEY_free(pk); return ret; } |