From: Dr. David von Oheimb Date: Wed, 12 Aug 2020 15:37:50 +0000 (+0200) Subject: Fix mem leaks on PKCS#12 read error in PKCS12_key_gen_{asc,utf8} X-Git-Tag: openssl-3.0.0-alpha7~547 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed4faae00cdab23244704660c099e41ec64f5dc0;p=thirdparty%2Fopenssl.git Fix mem leaks on PKCS#12 read error in PKCS12_key_gen_{asc,utf8} Reviewed-by: Richard Levitte Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/12639) --- diff --git a/crypto/pkcs12/p12_key.c b/crypto/pkcs12/p12_key.c index a40ae4cbe89..bbe212d125c 100644 --- a/crypto/pkcs12/p12_key.c +++ b/crypto/pkcs12/p12_key.c @@ -33,10 +33,8 @@ int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt, } ret = PKCS12_key_gen_uni(unipass, uniplen, salt, saltlen, id, iter, n, out, md_type); - if (ret <= 0) - return 0; OPENSSL_clear_free(unipass, uniplen); - return ret; + return ret > 0; } int PKCS12_key_gen_utf8(const char *pass, int passlen, unsigned char *salt, @@ -56,10 +54,8 @@ int PKCS12_key_gen_utf8(const char *pass, int passlen, unsigned char *salt, } ret = PKCS12_key_gen_uni(unipass, uniplen, salt, saltlen, id, iter, n, out, md_type); - if (ret <= 0) - return 0; OPENSSL_clear_free(unipass, uniplen); - return ret; + return ret > 0; } int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt,