summaryrefslogtreecommitdiffstats
path: root/crypto/pkcs12/p12_kiss.c
diff options
context:
space:
mode:
authorBernd Edlinger <bernd.edlinger@hotmail.de>2017-08-12 10:02:09 +0200
committerBernd Edlinger <bernd.edlinger@hotmail.de>2017-08-17 18:03:46 +0200
commite3348cfe15ac556278d0f30f7e17749e1bf1856d (patch)
tree10940613dcbf519cb02758e039198f989151bf3b /crypto/pkcs12/p12_kiss.c
parentd46d2da41c75ff765c914bf1c19063e97c8c519a (diff)
Clear outputs in PKCS12_parse error handling.
Reviewed-by: Andy Polyakov <appro@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4146)
Diffstat (limited to 'crypto/pkcs12/p12_kiss.c')
-rw-r--r--crypto/pkcs12/p12_kiss.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/crypto/pkcs12/p12_kiss.c b/crypto/pkcs12/p12_kiss.c
index 9aa3c90c4e..1841f78f69 100644
--- a/crypto/pkcs12/p12_kiss.c
+++ b/crypto/pkcs12/p12_kiss.c
@@ -84,6 +84,12 @@ int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
{
STACK_OF(X509) *ocerts = NULL;
X509 *x = NULL;
+
+ if (pkey)
+ *pkey = NULL;
+ if (cert)
+ *cert = NULL;
+
/* Check for NULL PKCS12 structure */
if (!p12) {
@@ -92,11 +98,6 @@ int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
return 0;
}
- if (pkey)
- *pkey = NULL;
- if (cert)
- *cert = NULL;
-
/* Check the mac */
/*
@@ -125,7 +126,7 @@ int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
if (!ocerts) {
PKCS12err(PKCS12_F_PKCS12_PARSE, ERR_R_MALLOC_FAILURE);
- return 0;
+ goto err;
}
if (!parse_pk12(p12, pass, -1, pkey, ocerts)) {
@@ -163,10 +164,14 @@ int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert,
err:
- if (pkey && *pkey)
+ if (pkey) {
EVP_PKEY_free(*pkey);
- if (cert && *cert)
+ *pkey = NULL;
+ }
+ if (cert) {
X509_free(*cert);
+ *cert = NULL;
+ }
if (x)
X509_free(x);
if (ocerts)