diff options
| author | tobhe <> | 2022-11-08 19:17:05 +0000 |
|---|---|---|
| committer | tobhe <> | 2022-11-08 19:17:05 +0000 |
| commit | f7bbcf1f4086b29ea35299ac0eb719cc157e526f (patch) | |
| tree | a50542336e4d580ff296dcd73c5ec87438808827 /src | |
| parent | 825db04c6828a0069e92e417fe752efcc8be7c74 (diff) | |
| download | openbsd-f7bbcf1f4086b29ea35299ac0eb719cc157e526f.tar.gz openbsd-f7bbcf1f4086b29ea35299ac0eb719cc157e526f.tar.bz2 openbsd-f7bbcf1f4086b29ea35299ac0eb719cc157e526f.zip | |
Fix leak of pk if EVP_PKEY_set1_DSA() fails.
Found with CodeChecker
ok jsing@
Diffstat (limited to 'src')
| -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 | } |
