From 76fc0c1130db1fe7c3d20b66da51f81aa0fdf89c Mon Sep 17 00:00:00 2001 From: tobhe <> Date: Thu, 10 Nov 2022 12:37:00 +0000 Subject: Fix a few more leaks in *_print() functions. ok jsing@ --- src/lib/libcrypto/ec/eck_prn.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'src/lib/libcrypto/ec') diff --git a/src/lib/libcrypto/ec/eck_prn.c b/src/lib/libcrypto/ec/eck_prn.c index c2fd2ebc85..058ae57de5 100644 --- a/src/lib/libcrypto/ec/eck_prn.c +++ b/src/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; } -- cgit v1.2.3-55-g6feb