diff options
author | tobhe <> | 2022-11-10 12:37:00 +0000 |
---|---|---|
committer | tobhe <> | 2022-11-10 12:37:00 +0000 |
commit | 27cfbee98d1ded4c10ba4f51d87f6bf6cf802cc8 (patch) | |
tree | 0e7c13bf24eb44de4251378b332c445a5ccb65c0 | |
parent | d331786cfdba704608438b4b33c00d6b283f4adf (diff) | |
download | openbsd-27cfbee98d1ded4c10ba4f51d87f6bf6cf802cc8.tar.gz openbsd-27cfbee98d1ded4c10ba4f51d87f6bf6cf802cc8.tar.bz2 openbsd-27cfbee98d1ded4c10ba4f51d87f6bf6cf802cc8.zip |
Fix a few more leaks in *_print() functions.
ok jsing@
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_prn.c | 14 | ||||
-rw-r--r-- | src/lib/libcrypto/ec/eck_prn.c | 28 |
2 files changed, 28 insertions, 14 deletions
diff --git a/src/lib/libcrypto/dsa/dsa_prn.c b/src/lib/libcrypto/dsa/dsa_prn.c index a26f3cfc6a..a2063283ea 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.7 2022/11/08 19:17:05 tobhe Exp $ */ | 1 | /* $OpenBSD: dsa_prn.c,v 1.8 2022/11/10 12:37:00 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 | */ |
@@ -116,12 +116,16 @@ int | |||
116 | DSAparams_print(BIO *bp, const DSA *x) | 116 | DSAparams_print(BIO *bp, const DSA *x) |
117 | { | 117 | { |
118 | EVP_PKEY *pk; | 118 | EVP_PKEY *pk; |
119 | int ret; | 119 | int ret = 0; |
120 | |||
121 | if ((pk = EVP_PKEY_new()) == NULL) | ||
122 | goto err; | ||
123 | |||
124 | if (!EVP_PKEY_set1_DSA(pk, (DSA *)x)) | ||
125 | goto err; | ||
120 | 126 | ||
121 | pk = EVP_PKEY_new(); | ||
122 | if (!pk || !EVP_PKEY_set1_DSA(pk, (DSA *)x)) | ||
123 | return 0; | ||
124 | ret = EVP_PKEY_print_params(bp, pk, 4, NULL); | 127 | ret = EVP_PKEY_print_params(bp, pk, 4, NULL); |
128 | err: | ||
125 | EVP_PKEY_free(pk); | 129 | EVP_PKEY_free(pk); |
126 | return ret; | 130 | return ret; |
127 | } | 131 | } |
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 @@ | |||
1 | /* $OpenBSD: eck_prn.c,v 1.17 2021/04/20 17:12:43 tb Exp $ */ | 1 | /* $OpenBSD: eck_prn.c,v 1.18 2022/11/10 12:37:00 tobhe Exp $ */ |
2 | /* | 2 | /* |
3 | * Written by Nils Larsch for the OpenSSL project. | 3 | * Written by Nils Larsch for the OpenSSL project. |
4 | */ | 4 | */ |
@@ -121,11 +121,16 @@ int | |||
121 | EC_KEY_print(BIO * bp, const EC_KEY * x, int off) | 121 | EC_KEY_print(BIO * bp, const EC_KEY * x, int off) |
122 | { | 122 | { |
123 | EVP_PKEY *pk; | 123 | EVP_PKEY *pk; |
124 | int ret; | 124 | int ret = 0; |
125 | pk = EVP_PKEY_new(); | 125 | |
126 | if (!pk || !EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) | 126 | if ((pk = EVP_PKEY_new()) == NULL) |
127 | return 0; | 127 | goto err; |
128 | |||
129 | if (!EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) | ||
130 | goto err; | ||
131 | |||
128 | ret = EVP_PKEY_print_private(bp, pk, off, NULL); | 132 | ret = EVP_PKEY_print_private(bp, pk, off, NULL); |
133 | err: | ||
129 | EVP_PKEY_free(pk); | 134 | EVP_PKEY_free(pk); |
130 | return ret; | 135 | return ret; |
131 | } | 136 | } |
@@ -134,11 +139,16 @@ int | |||
134 | ECParameters_print(BIO * bp, const EC_KEY * x) | 139 | ECParameters_print(BIO * bp, const EC_KEY * x) |
135 | { | 140 | { |
136 | EVP_PKEY *pk; | 141 | EVP_PKEY *pk; |
137 | int ret; | 142 | int ret = 0; |
138 | pk = EVP_PKEY_new(); | 143 | |
139 | if (!pk || !EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) | 144 | if ((pk = EVP_PKEY_new()) == NULL) |
140 | return 0; | 145 | goto err; |
146 | |||
147 | if (!EVP_PKEY_set1_EC_KEY(pk, (EC_KEY *) x)) | ||
148 | goto err; | ||
149 | |||
141 | ret = EVP_PKEY_print_params(bp, pk, 4, NULL); | 150 | ret = EVP_PKEY_print_params(bp, pk, 4, NULL); |
151 | err: | ||
142 | EVP_PKEY_free(pk); | 152 | EVP_PKEY_free(pk); |
143 | return ret; | 153 | return ret; |
144 | } | 154 | } |