diff options
Diffstat (limited to 'crypto/x509')
-rw-r--r-- | crypto/x509/by_dir.c | 2 | ||||
-rw-r--r-- | crypto/x509/v3_cpols.c | 7 | ||||
-rw-r--r-- | crypto/x509/v3_crld.c | 6 | ||||
-rw-r--r-- | crypto/x509/v3_info.c | 2 | ||||
-rw-r--r-- | crypto/x509/v3_ncons.c | 10 | ||||
-rw-r--r-- | crypto/x509/v3_pci.c | 3 | ||||
-rw-r--r-- | crypto/x509/v3_pcons.c | 3 | ||||
-rw-r--r-- | crypto/x509/v3_purp.c | 4 | ||||
-rw-r--r-- | crypto/x509/v3_sxnet.c | 3 | ||||
-rw-r--r-- | crypto/x509/v3_utl.c | 9 | ||||
-rw-r--r-- | crypto/x509/x509_trs.c | 2 | ||||
-rw-r--r-- | crypto/x509/x509_vfy.c | 7 | ||||
-rw-r--r-- | crypto/x509/x509_vpm.c | 10 | ||||
-rw-r--r-- | crypto/x509/x_all.c | 6 | ||||
-rw-r--r-- | crypto/x509/x_name.c | 6 | ||||
-rw-r--r-- | crypto/x509/x_pubkey.c | 31 |
16 files changed, 63 insertions, 48 deletions
diff --git a/crypto/x509/by_dir.c b/crypto/x509/by_dir.c index d38080fb0c..69950b7d61 100644 --- a/crypto/x509/by_dir.c +++ b/crypto/x509/by_dir.c @@ -156,7 +156,7 @@ static int add_cert_dir(BY_DIR *ctx, const char *dir, int type) size_t len; const char *s, *ss, *p; - if (dir == NULL || !*dir) { + if (dir == NULL || *dir == '\0') { X509err(X509_F_ADD_CERT_DIR, X509_R_INVALID_DIRECTORY); return 0; } diff --git a/crypto/x509/v3_cpols.c b/crypto/x509/v3_cpols.c index f9a239b6f2..e70ab61d50 100644 --- a/crypto/x509/v3_cpols.c +++ b/crypto/x509/v3_cpols.c @@ -124,8 +124,9 @@ static STACK_OF(POLICYINFO) *r2i_certpol(X509V3_EXT_METHOD *method, continue; } else if (*pstr == '@') { STACK_OF(CONF_VALUE) *polsect; + polsect = X509V3_get_section(ctx, pstr + 1); - if (!polsect) { + if (polsect == NULL) { X509V3err(X509V3_F_R2I_CERTPOL, X509V3_R_INVALID_SECTION); X509V3_conf_err(cnf); @@ -221,7 +222,7 @@ static POLICYINFO *policy_section(X509V3_CTX *ctx, X509V3_section_free(ctx, unot); if (!qual) goto err; - if (!pol->qualifiers) + if (pol->qualifiers == NULL) pol->qualifiers = sk_POLICYQUALINFO_new_null(); if (!sk_POLICYQUALINFO_push(pol->qualifiers, qual)) goto merr; @@ -232,7 +233,7 @@ static POLICYINFO *policy_section(X509V3_CTX *ctx, goto err; } } - if (!pol->policyid) { + if (pol->policyid == NULL) { X509V3err(X509V3_F_POLICY_SECTION, X509V3_R_NO_POLICY_IDENTIFIER); goto err; } diff --git a/crypto/x509/v3_crld.c b/crypto/x509/v3_crld.c index c3517b817c..4b60752ae8 100644 --- a/crypto/x509/v3_crld.c +++ b/crypto/x509/v3_crld.c @@ -168,7 +168,7 @@ static int set_reasons(ASN1_BIT_STRING **preas, char *value) break; } } - if (!pbn->lname) + if (pbn->lname == NULL) goto err; } ret = 1; @@ -222,7 +222,7 @@ static DIST_POINT *crldp_from_section(X509V3_CTX *ctx, goto err; } else if (strcmp(cnf->name, "CRLissuer") == 0) { point->CRLissuer = gnames_from_sectname(ctx, cnf->value); - if (!point->CRLissuer) + if (point->CRLissuer == NULL) goto err; } } @@ -258,7 +258,7 @@ static void *v2i_crld(const X509V3_EXT_METHOD *method, goto err; point = crldp_from_section(ctx, dpsect); X509V3_section_free(ctx, dpsect); - if (!point) + if (point == NULL) goto err; sk_DIST_POINT_push(crld, point); /* no failure as it was reserved */ } else { diff --git a/crypto/x509/v3_info.c b/crypto/x509/v3_info.c index 0b97c9663f..c50cfd1f34 100644 --- a/crypto/x509/v3_info.c +++ b/crypto/x509/v3_info.c @@ -123,7 +123,7 @@ static AUTHORITY_INFO_ACCESS *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD } sk_ACCESS_DESCRIPTION_push(ainfo, acc); /* Cannot fail due to reserve */ ptmp = strchr(cnf->name, ';'); - if (!ptmp) { + if (ptmp == NULL) { X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS, X509V3_R_INVALID_SYNTAX); goto err; diff --git a/crypto/x509/v3_ncons.c b/crypto/x509/v3_ncons.c index 3be0c05fce..927aa8f982 100644 --- a/crypto/x509/v3_ncons.c +++ b/crypto/x509/v3_ncons.c @@ -561,8 +561,9 @@ static int nc_dns(ASN1_IA5STRING *dns, ASN1_IA5STRING *base) { char *baseptr = (char *)base->data; char *dnsptr = (char *)dns->data; + /* Empty matches everything */ - if (!*baseptr) + if (*baseptr == '\0') return X509_V_OK; /* * Otherwise can add zero or more components on the left so compare RHS @@ -628,8 +629,9 @@ static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base) const char *hostptr = (char *)uri->data; const char *p = strchr(hostptr, ':'); int hostlen; + /* Check for foo:// and skip past it */ - if (!p || (p[1] != '/') || (p[2] != '/')) + if (p == NULL || p[1] != '/' || p[2] != '/') return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX; hostptr = p + 3; @@ -639,10 +641,10 @@ static int nc_uri(ASN1_IA5STRING *uri, ASN1_IA5STRING *base) p = strchr(hostptr, ':'); /* Otherwise look for trailing slash */ - if (!p) + if (p == NULL) p = strchr(hostptr, '/'); - if (!p) + if (p == NULL) hostlen = strlen(hostptr); else hostlen = p - hostptr; diff --git a/crypto/x509/v3_pci.c b/crypto/x509/v3_pci.c index 856b70d9b5..fb5f35a5ab 100644 --- a/crypto/x509/v3_pci.c +++ b/crypto/x509/v3_pci.c @@ -116,7 +116,8 @@ static int process_pci_value(CONF_VALUE *val, } else if (strcmp(val->name, "policy") == 0) { unsigned char *tmp_data = NULL; long val_len; - if (!*policy) { + + if (*policy == NULL) { *policy = ASN1_OCTET_STRING_new(); if (*policy == NULL) { X509V3err(X509V3_F_PROCESS_PCI_VALUE, ERR_R_MALLOC_FAILURE); diff --git a/crypto/x509/v3_pcons.c b/crypto/x509/v3_pcons.c index e6d50a6fe7..33c08cfdaa 100644 --- a/crypto/x509/v3_pcons.c +++ b/crypto/x509/v3_pcons.c @@ -78,7 +78,8 @@ static void *v2i_POLICY_CONSTRAINTS(const X509V3_EXT_METHOD *method, goto err; } } - if (!pcons->inhibitPolicyMapping && !pcons->requireExplicitPolicy) { + if (pcons->inhibitPolicyMapping == NULL + && pcons->requireExplicitPolicy == NULL) { X509V3err(X509V3_F_V2I_POLICY_CONSTRAINTS, X509V3_R_ILLEGAL_EMPTY_EXTENSION); goto err; diff --git a/crypto/x509/v3_purp.c b/crypto/x509/v3_purp.c index 3248e286ae..10fd0f73f3 100644 --- a/crypto/x509/v3_purp.c +++ b/crypto/x509/v3_purp.c @@ -178,7 +178,7 @@ int X509_PURPOSE_add(int id, int trust, int flags, /* dup supplied name */ ptmp->name = OPENSSL_strdup(name); ptmp->sname = OPENSSL_strdup(sname); - if (!ptmp->name || !ptmp->sname) { + if (ptmp->name == NULL|| ptmp->sname == NULL) { X509V3err(X509V3_F_X509_PURPOSE_ADD, ERR_R_MALLOC_FAILURE); goto err; } @@ -216,7 +216,7 @@ int X509_PURPOSE_add(int id, int trust, int flags, static void xptable_free(X509_PURPOSE *p) { - if (!p) + if (p == NULL) return; if (p->flags & X509_PURPOSE_DYNAMIC) { if (p->flags & X509_PURPOSE_DYNAMIC_NAME) { diff --git a/crypto/x509/v3_sxnet.c b/crypto/x509/v3_sxnet.c index ddb2a0312e..072b8efe82 100644 --- a/crypto/x509/v3_sxnet.c +++ b/crypto/x509/v3_sxnet.c @@ -139,7 +139,8 @@ int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *zone, const char *user, { SXNET *sx = NULL; SXNETID *id = NULL; - if (!psx || !zone || !user) { + + if (psx == NULL || zone == NULL || user == NULL) { X509V3err(X509V3_F_SXNET_ADD_ID_INTEGER, X509V3_R_INVALID_NULL_ARGUMENT); return 0; diff --git a/crypto/x509/v3_utl.c b/crypto/x509/v3_utl.c index 1516d988f0..50fa404996 100644 --- a/crypto/x509/v3_utl.c +++ b/crypto/x509/v3_utl.c @@ -380,14 +380,14 @@ static char *strip_spaces(char *name) p = name; while (*p && ossl_isspace(*p)) p++; - if (!*p) + if (*p == '\0') return NULL; q = p + strlen(p) - 1; while ((q != p) && ossl_isspace(*q)) q--; if (p != q) q[1] = 0; - if (!*p) + if (*p == '\0') return NULL; return p; } @@ -989,11 +989,12 @@ ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc) unsigned char ipout[32]; char *iptmp = NULL, *p; int iplen1, iplen2; + p = strchr(ipasc, '/'); - if (!p) + if (p == NULL) return NULL; iptmp = OPENSSL_strdup(ipasc); - if (!iptmp) + if (iptmp == NULL) return NULL; p = iptmp + (p - ipasc); *p++ = 0; diff --git a/crypto/x509/x509_trs.c b/crypto/x509/x509_trs.c index b6a45acbcd..b077ba584f 100644 --- a/crypto/x509/x509_trs.c +++ b/crypto/x509/x509_trs.c @@ -184,7 +184,7 @@ int X509_TRUST_add(int id, int flags, int (*ck) (X509_TRUST *, X509 *, int), static void trtable_free(X509_TRUST *p) { - if (!p) + if (p == NULL) return; if (p->flags & X509_TRUST_DYNAMIC) { if (p->flags & X509_TRUST_DYNAMIC_NAME) diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c index 126df99142..1e2e4cd557 100644 --- a/crypto/x509/x509_vfy.c +++ b/crypto/x509/x509_vfy.c @@ -2134,10 +2134,10 @@ int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose, { int idx; /* If purpose not set use default */ - if (!purpose) + if (purpose == 0) purpose = def_purpose; /* If we have a purpose then check it is valid */ - if (purpose) { + if (purpose != 0) { X509_PURPOSE *ptmp; idx = X509_PURPOSE_get_by_id(purpose); if (idx == -1) { @@ -2502,8 +2502,9 @@ int X509_STORE_CTX_get_num_untrusted(X509_STORE_CTX *ctx) int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name) { const X509_VERIFY_PARAM *param; + param = X509_VERIFY_PARAM_lookup(name); - if (!param) + if (param == NULL) return 0; return X509_VERIFY_PARAM_inherit(ctx->param, param); } diff --git a/crypto/x509/x509_vpm.c b/crypto/x509/x509_vpm.c index 81a0ec997e..782fa136f2 100644 --- a/crypto/x509/x509_vpm.c +++ b/crypto/x509/x509_vpm.c @@ -332,9 +332,9 @@ void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t) int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param, ASN1_OBJECT *policy) { - if (!param->policies) { + if (param->policies == NULL) { param->policies = sk_ASN1_OBJECT_new_null(); - if (!param->policies) + if (param->policies == NULL) return 0; } if (!sk_ASN1_OBJECT_push(param->policies, policy)) @@ -348,17 +348,17 @@ int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param, int i; ASN1_OBJECT *oid, *doid; - if (!param) + if (param == NULL) return 0; sk_ASN1_OBJECT_pop_free(param->policies, ASN1_OBJECT_free); - if (!policies) { + if (policies == NULL) { param->policies = NULL; return 1; } param->policies = sk_ASN1_OBJECT_new_null(); - if (!param->policies) + if (param->policies == NULL) return 0; for (i = 0; i < sk_ASN1_OBJECT_num(policies); i++) { diff --git a/crypto/x509/x_all.c b/crypto/x509/x_all.c index 43b29d3bc6..9517169b8b 100644 --- a/crypto/x509/x_all.c +++ b/crypto/x509/x_all.c @@ -607,8 +607,9 @@ int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, const EVP_PKEY *key) { PKCS8_PRIV_KEY_INFO *p8inf; int ret; + p8inf = EVP_PKEY2PKCS8(key); - if (!p8inf) + if (p8inf == NULL) return 0; ret = i2d_PKCS8_PRIV_KEY_INFO_fp(fp, p8inf); PKCS8_PRIV_KEY_INFO_free(p8inf); @@ -654,8 +655,9 @@ int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, const EVP_PKEY *key) { PKCS8_PRIV_KEY_INFO *p8inf; int ret; + p8inf = EVP_PKEY2PKCS8(key); - if (!p8inf) + if (p8inf == NULL) return 0; ret = i2d_PKCS8_PRIV_KEY_INFO_bio(bp, p8inf); PKCS8_PRIV_KEY_INFO_free(p8inf); diff --git a/crypto/x509/x_name.c b/crypto/x509/x_name.c index 33faacf5dd..59d6531bf8 100644 --- a/crypto/x509/x_name.c +++ b/crypto/x509/x_name.c @@ -114,7 +114,7 @@ static void x509_name_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) { X509_NAME *a; - if (!pval || !*pval) + if (pval == NULL || *pval == NULL) return; a = (X509_NAME *)*pval; @@ -503,9 +503,9 @@ int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase) l = 80 - 2 - obase; b = X509_NAME_oneline(name, NULL, 0); - if (!b) + if (b == NULL) return 0; - if (!*b) { + if (*b == '\0') { OPENSSL_free(b); return 1; } diff --git a/crypto/x509/x_pubkey.c b/crypto/x509/x_pubkey.c index 6e8540835f..44b08e8bdf 100644 --- a/crypto/x509/x_pubkey.c +++ b/crypto/x509/x_pubkey.c @@ -185,16 +185,17 @@ EVP_PKEY *d2i_PUBKEY(EVP_PKEY **a, const unsigned char **pp, long length) X509_PUBKEY *xpk; EVP_PKEY *pktmp; const unsigned char *q; + q = *pp; xpk = d2i_X509_PUBKEY(NULL, &q, length); - if (!xpk) + if (xpk == NULL) return NULL; pktmp = X509_PUBKEY_get(xpk); X509_PUBKEY_free(xpk); - if (!pktmp) + if (pktmp == NULL) return NULL; *pp = q; - if (a) { + if (a != NULL) { EVP_PKEY_free(*a); *a = pktmp; } @@ -230,16 +231,17 @@ RSA *d2i_RSA_PUBKEY(RSA **a, const unsigned char **pp, long length) EVP_PKEY *pkey; RSA *key; const unsigned char *q; + q = *pp; pkey = d2i_PUBKEY(NULL, &q, length); - if (!pkey) + if (pkey == NULL) return NULL; key = EVP_PKEY_get1_RSA(pkey); EVP_PKEY_free(pkey); - if (!key) + if (key == NULL) return NULL; *pp = q; - if (a) { + if (a != NULL) { RSA_free(*a); *a = key; } @@ -271,16 +273,17 @@ DSA *d2i_DSA_PUBKEY(DSA **a, const unsigned char **pp, long length) EVP_PKEY *pkey; DSA *key; const unsigned char *q; + q = *pp; pkey = d2i_PUBKEY(NULL, &q, length); - if (!pkey) + if (pkey == NULL) return NULL; key = EVP_PKEY_get1_DSA(pkey); EVP_PKEY_free(pkey); - if (!key) + if (key == NULL) return NULL; *pp = q; - if (a) { + if (a != NULL) { DSA_free(*a); *a = key; } @@ -312,16 +315,17 @@ EC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp, long length) EVP_PKEY *pkey; EC_KEY *key; const unsigned char *q; + q = *pp; pkey = d2i_PUBKEY(NULL, &q, length); - if (!pkey) + if (pkey == NULL) return NULL; key = EVP_PKEY_get1_EC_KEY(pkey); EVP_PKEY_free(pkey); - if (!key) + if (key == NULL) return NULL; *pp = q; - if (a) { + if (a != NULL) { EC_KEY_free(*a); *a = key; } @@ -332,7 +336,8 @@ int i2d_EC_PUBKEY(const EC_KEY *a, unsigned char **pp) { EVP_PKEY *pktmp; int ret; - if (!a) + + if (a == NULL) return 0; if ((pktmp = EVP_PKEY_new()) == NULL) { ASN1err(ASN1_F_I2D_EC_PUBKEY, ERR_R_MALLOC_FAILURE); |