diff options
author | tobhe <> | 2022-11-08 19:17:05 +0000 |
---|---|---|
committer | tobhe <> | 2022-11-08 19:17:05 +0000 |
commit | 5ca237600d9aeab76b21ef0f92fec99dc84bdc22 (patch) | |
tree | a50542336e4d580ff296dcd73c5ec87438808827 | |
parent | 27c24322af3fca9f304fa1354083afab3f7936ac (diff) | |
download | openbsd-5ca237600d9aeab76b21ef0f92fec99dc84bdc22.tar.gz openbsd-5ca237600d9aeab76b21ef0f92fec99dc84bdc22.tar.bz2 openbsd-5ca237600d9aeab76b21ef0f92fec99dc84bdc22.zip |
Fix leak of pk if EVP_PKEY_set1_DSA() fails.
Found with CodeChecker
ok jsing@
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_prn.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/lib/libcrypto/dsa/dsa_prn.c b/src/lib/libcrypto/dsa/dsa_prn.c index fb5e35f909..a26f3cfc6a 100644 --- a/src/lib/libcrypto/dsa/dsa_prn.c +++ b/src/lib/libcrypto/dsa/dsa_prn.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dsa_prn.c,v 1.6 2017/01/29 17:49:22 beck Exp $ */ | 1 | /* $OpenBSD: dsa_prn.c,v 1.7 2022/11/08 19:17:05 tobhe Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project 2006. | 3 | * project 2006. |
4 | */ | 4 | */ |
@@ -98,12 +98,16 @@ int | |||
98 | DSA_print(BIO *bp, const DSA *x, int off) | 98 | DSA_print(BIO *bp, const DSA *x, int off) |
99 | { | 99 | { |
100 | EVP_PKEY *pk; | 100 | EVP_PKEY *pk; |
101 | int ret; | 101 | int ret = 0; |
102 | |||
103 | if ((pk = EVP_PKEY_new()) == NULL) | ||
104 | goto err; | ||
105 | |||
106 | if (!EVP_PKEY_set1_DSA(pk, (DSA *)x)) | ||
107 | goto err; | ||
102 | 108 | ||
103 | pk = EVP_PKEY_new(); | ||
104 | if (!pk || !EVP_PKEY_set1_DSA(pk, (DSA *)x)) | ||
105 | return 0; | ||
106 | ret = EVP_PKEY_print_private(bp, pk, off, NULL); | 109 | ret = EVP_PKEY_print_private(bp, pk, off, NULL); |
110 | err: | ||
107 | EVP_PKEY_free(pk); | 111 | EVP_PKEY_free(pk); |
108 | return ret; | 112 | return ret; |
109 | } | 113 | } |