summaryrefslogtreecommitdiff
path: root/lib/libcrypto
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2019-10-31 12:32:49 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2019-10-31 12:32:49 +0000
commite74b0e424426ca73d4774d14aae25753255a18aa (patch)
tree1dd053c18df03b8f7c769c05ac74062959fc1b5f /lib/libcrypto
parent02912c8bcc2b1e6e3a3acdc4b299d3a785cb9c42 (diff)
Avoid potentially leaking pub_exp in pkey_rsa_copy().
ok inoguchi@
Diffstat (limited to 'lib/libcrypto')
-rw-r--r--lib/libcrypto/rsa/rsa_pmeth.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/libcrypto/rsa/rsa_pmeth.c b/lib/libcrypto/rsa/rsa_pmeth.c
index 78f6532a5f3..fd567658c21 100644
--- a/lib/libcrypto/rsa/rsa_pmeth.c
+++ b/lib/libcrypto/rsa/rsa_pmeth.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rsa_pmeth.c,v 1.24 2019/10/29 08:52:02 jsing Exp $ */
+/* $OpenBSD: rsa_pmeth.c,v 1.25 2019/10/31 12:32:48 jsing Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
@@ -127,9 +127,9 @@ pkey_rsa_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
sctx = src->data;
dctx = dst->data;
dctx->nbits = sctx->nbits;
- if (sctx->pub_exp) {
- dctx->pub_exp = BN_dup(sctx->pub_exp);
- if (!dctx->pub_exp)
+ if (sctx->pub_exp != NULL) {
+ BN_free(dctx->pub_exp);
+ if ((dctx->pub_exp = BN_dup(sctx->pub_exp)) == NULL)
return 0;
}
dctx->pad_mode = sctx->pad_mode;