diff options
author | Rich Salz <rsalz@akamai.com> | 2019-09-16 15:28:57 -0400 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2019-10-09 21:32:15 +0200 |
commit | 12a765a5235f181c2f4992b615eb5f892c368e88 (patch) | |
tree | 67ece1a3fb210bd4895aea73649773fc912a60d6 /crypto/pkcs12/p12_crt.c | |
parent | 3a4e43de473ee80347036d78163889b6b1221210 (diff) |
Explicitly test against NULL; do not use !p or similar
Also added blanks lines after declarations in a couple of places.
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9916)
Diffstat (limited to 'crypto/pkcs12/p12_crt.c')
-rw-r--r-- | crypto/pkcs12/p12_crt.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/crypto/pkcs12/p12_crt.c b/crypto/pkcs12/p12_crt.c index 063a5bb010..94bd3e1636 100644 --- a/crypto/pkcs12/p12_crt.c +++ b/crypto/pkcs12/p12_crt.c @@ -54,7 +54,7 @@ PKCS12 *PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey, X509 * if (!mac_iter) mac_iter = 1; - if (!pkey && !cert && !ca) { + if (pkey == NULL && cert == NULL && ca == NULL) { PKCS12err(PKCS12_F_PKCS12_CREATE, PKCS12_R_INVALID_NULL_ARGUMENT); return NULL; } @@ -110,7 +110,7 @@ PKCS12 *PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey, X509 * p12 = PKCS12_add_safes(safes, 0); - if (!p12) + if (p12 == NULL) goto err; sk_PKCS7_pop_free(safes, PKCS7_free); @@ -208,13 +208,12 @@ int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags, PKCS7 *p7 = NULL; int free_safes = 0; - if (!*psafes) { + if (*psafes == NULL) { *psafes = sk_PKCS7_new_null(); - if (!*psafes) + if (*psafes == NULL) return 0; free_safes = 1; - } else - free_safes = 0; + } if (nid_safe == 0) #ifdef OPENSSL_NO_RC2 @@ -227,7 +226,7 @@ int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags, p7 = PKCS12_pack_p7data(bags); else p7 = PKCS12_pack_p7encdata(nid_safe, pass, -1, NULL, 0, iter, bags); - if (!p7) + if (p7 == NULL) goto err; if (!sk_PKCS7_push(*psafes, p7)) @@ -248,16 +247,16 @@ int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags, static int pkcs12_add_bag(STACK_OF(PKCS12_SAFEBAG) **pbags, PKCS12_SAFEBAG *bag) { - int free_bags; - if (!pbags) + int free_bags = 0; + + if (pbags == NULL) return 1; - if (!*pbags) { + if (*pbags == NULL) { *pbags = sk_PKCS12_SAFEBAG_new_null(); - if (!*pbags) + if (*pbags == NULL) return 0; free_bags = 1; - } else - free_bags = 0; + } if (!sk_PKCS12_SAFEBAG_push(*pbags, bag)) { if (free_bags) { @@ -274,11 +273,11 @@ static int pkcs12_add_bag(STACK_OF(PKCS12_SAFEBAG) **pbags, PKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int nid_p7) { PKCS12 *p12; + if (nid_p7 <= 0) nid_p7 = NID_pkcs7_data; p12 = PKCS12_init(nid_p7); - - if (!p12) + if (p12 == NULL) return NULL; if (!PKCS12_pack_authsafes(p12, safes)) { |