diff options
author | Pauli <paul.dale@oracle.com> | 2020-09-14 07:40:58 +1000 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2020-09-16 07:22:43 +1000 |
commit | e2d66c0d007ad8bcf80890dadf681135d24d86cd (patch) | |
tree | 663b13bc1f319b7b15ef8285bbba3d14c74cb62c /crypto | |
parent | 48ff651eccf2f43ddbc221a0f9ddac57169aa255 (diff) |
PKCS#8: free data on error path in newpass_bag
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/12870)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/pkcs12/p12_npas.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/crypto/pkcs12/p12_npas.c b/crypto/pkcs12/p12_npas.c index ee35c45abb..7f04ce10de 100644 --- a/crypto/pkcs12/p12_npas.c +++ b/crypto/pkcs12/p12_npas.c @@ -157,8 +157,10 @@ static int newpass_bag(PKCS12_SAFEBAG *bag, const char *oldpass, if ((p8 = PKCS8_decrypt(bag->value.shkeybag, oldpass, -1)) == NULL) return 0; X509_SIG_get0(bag->value.shkeybag, &shalg, NULL); - if (!alg_get(shalg, &p8_nid, &p8_iter, &p8_saltlen)) + if (!alg_get(shalg, &p8_nid, &p8_iter, &p8_saltlen)) { + PKCS8_PRIV_KEY_INFO_free(p8); return 0; + } p8new = PKCS8_encrypt(p8_nid, NULL, newpass, -1, NULL, p8_saltlen, p8_iter, p8); PKCS8_PRIV_KEY_INFO_free(p8); |