summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormiod <>2016-11-05 13:02:34 +0000
committermiod <>2016-11-05 13:02:34 +0000
commit7f9071cab071a0d27937f32c7ab76f019b3d8135 (patch)
treec1ec2d42b911b07a042269ab0d3b1fec697cda61 /src
parent0a57be4fd4153555c860c3f645ccde030418c453 (diff)
downloadopenbsd-7f9071cab071a0d27937f32c7ab76f019b3d8135.tar.gz
openbsd-7f9071cab071a0d27937f32c7ab76f019b3d8135.tar.bz2
openbsd-7f9071cab071a0d27937f32c7ab76f019b3d8135.zip
Do not leak the ressources possibly allocated by EVP_MD_CTX_init() in the
trivial error path of PKCS12_key_gen_uni(). ok beck@ jsing@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/pkcs12/p12_key.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lib/libcrypto/pkcs12/p12_key.c b/src/lib/libcrypto/pkcs12/p12_key.c
index 38f8a8194c..891f764c23 100644
--- a/src/lib/libcrypto/pkcs12/p12_key.c
+++ b/src/lib/libcrypto/pkcs12/p12_key.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p12_key.c,v 1.23 2015/09/10 15:56:25 jsing Exp $ */ 1/* $OpenBSD: p12_key.c,v 1.24 2016/11/05 13:02:34 miod 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 1999. 3 * project 1999.
4 */ 4 */
@@ -107,11 +107,12 @@ PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,
107 BIGNUM *Ij, *Bpl1; /* These hold Ij and B + 1 */ 107 BIGNUM *Ij, *Bpl1; /* These hold Ij and B + 1 */
108 EVP_MD_CTX ctx; 108 EVP_MD_CTX ctx;
109 109
110 EVP_MD_CTX_init(&ctx);
111 v = EVP_MD_block_size(md_type); 110 v = EVP_MD_block_size(md_type);
112 u = EVP_MD_size(md_type); 111 u = EVP_MD_size(md_type);
113 if (u < 0) 112 if (u < 0)
114 return 0; 113 return 0;
114
115 EVP_MD_CTX_init(&ctx);
115 D = malloc(v); 116 D = malloc(v);
116 Ai = malloc(u); 117 Ai = malloc(u);
117 B = malloc(v + 1); 118 B = malloc(v + 1);