Use p==NULL not !p (in if statements, mainly) Reviewed-by: Tim Hudson <tjh@openssl.org>
diff --git a/crypto/asn1/a_mbstr.c b/crypto/asn1/a_mbstr.c index 2ff496b..ddb2798 100644 --- a/crypto/asn1/a_mbstr.c +++ b/crypto/asn1/a_mbstr.c
@@ -235,7 +235,7 @@ cpyfunc = cpy_utf8; break; } - if (!(p = OPENSSL_malloc(outlen + 1))) { + if ((p = OPENSSL_malloc(outlen + 1)) == NULL) { if (free_out) ASN1_STRING_free(dest); ASN1err(ASN1_F_ASN1_MBSTRING_NCOPY, ERR_R_MALLOC_FAILURE);
diff --git a/crypto/asn1/a_time.c b/crypto/asn1/a_time.c index 7ff3de3..6114c52 100644 --- a/crypto/asn1/a_time.c +++ b/crypto/asn1/a_time.c
@@ -116,8 +116,8 @@ if (!ASN1_TIME_check(t)) return NULL; - if (!out || !*out) { - if (!(ret = ASN1_GENERALIZEDTIME_new())) + if (out == NULL || *out == NULL) { + if ((ret = ASN1_GENERALIZEDTIME_new()) == NULL) return NULL; if (out) *out = ret;
diff --git a/crypto/asn1/asn1_gen.c b/crypto/asn1/asn1_gen.c index 84d85e6..3ff1db8 100644 --- a/crypto/asn1/asn1_gen.c +++ b/crypto/asn1/asn1_gen.c
@@ -492,15 +492,12 @@ if (derlen < 0) goto bad; - - if (!(ret = ASN1_TYPE_new())) + if ((ret = ASN1_TYPE_new()) == NULL) goto bad; - - if (!(ret->value.asn1_string = ASN1_STRING_type_new(utype))) + if ((ret->value.asn1_string = ASN1_STRING_type_new(utype)) == NULL) goto bad; ret->type = utype; - ret->value.asn1_string->data = der; ret->value.asn1_string->length = derlen; @@ -631,15 +628,12 @@ static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype) { ASN1_TYPE *atmp = NULL; - CONF_VALUE vtmp; - unsigned char *rdata; long rdlen; - int no_unused = 1; - if (!(atmp = ASN1_TYPE_new())) { + if ((atmp = ASN1_TYPE_new()) == NULL) { ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE); return NULL; } @@ -676,7 +670,8 @@ ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_INTEGER_NOT_ASCII_FORMAT); goto bad_form; } - if (!(atmp->value.integer = s2i_ASN1_INTEGER(NULL, (char *)str))) { + if ((atmp->value.integer + = s2i_ASN1_INTEGER(NULL, (char *)str)) == NULL) { ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_INTEGER); goto bad_str; } @@ -687,7 +682,7 @@ ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_OBJECT_NOT_ASCII_FORMAT); goto bad_form; } - if (!(atmp->value.object = OBJ_txt2obj(str, 0))) { + if ((atmp->value.object = OBJ_txt2obj(str, 0)) == NULL) { ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_OBJECT); goto bad_str; } @@ -699,7 +694,7 @@ ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_TIME_NOT_ASCII_FORMAT); goto bad_form; } - if (!(atmp->value.asn1_string = ASN1_STRING_new())) { + if ((atmp->value.asn1_string = ASN1_STRING_new()) == NULL) { ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE); goto bad_str; } @@ -724,7 +719,6 @@ case V_ASN1_UNIVERSALSTRING: case V_ASN1_GENERALSTRING: case V_ASN1_NUMERICSTRING: - if (format == ASN1_GEN_FORMAT_ASCII) format = MBSTRING_ASC; else if (format == ASN1_GEN_FORMAT_UTF8) @@ -743,25 +737,20 @@ break; case V_ASN1_BIT_STRING: - case V_ASN1_OCTET_STRING: - - if (!(atmp->value.asn1_string = ASN1_STRING_new())) { + if ((atmp->value.asn1_string = ASN1_STRING_new()) == NULL) { ASN1err(ASN1_F_ASN1_STR2TYPE, ERR_R_MALLOC_FAILURE); goto bad_form; } if (format == ASN1_GEN_FORMAT_HEX) { - - if (!(rdata = string_to_hex((char *)str, &rdlen))) { + if ((rdata = string_to_hex((char *)str, &rdlen)) == NULL) { ASN1err(ASN1_F_ASN1_STR2TYPE, ASN1_R_ILLEGAL_HEX); goto bad_str; } - atmp->value.asn1_string->data = rdata; atmp->value.asn1_string->length = rdlen; atmp->value.asn1_string->type = utype; - } else if (format == ASN1_GEN_FORMAT_ASCII) ASN1_STRING_set(atmp->value.asn1_string, str, -1); else if ((format == ASN1_GEN_FORMAT_BITLIST)
diff --git a/crypto/asn1/asn_mime.c b/crypto/asn1/asn_mime.c index 2fe6cf9..9ce4013 100644 --- a/crypto/asn1/asn_mime.c +++ b/crypto/asn1/asn_mime.c
@@ -180,7 +180,8 @@ { BIO *b64; ASN1_VALUE *val; - if (!(b64 = BIO_new(BIO_f_base64()))) { + + if ((b64 = BIO_new(BIO_f_base64())) == NULL) { ASN1err(ASN1_F_B64_READ_ASN1, ERR_R_MALLOC_FAILURE); return 0; } @@ -427,12 +428,13 @@ if (bcont) *bcont = NULL; - if (!(headers = mime_parse_hdr(bio))) { + if ((headers = mime_parse_hdr(bio)) == NULL) { ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_MIME_PARSE_ERROR); return NULL; } - if (!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) { + if ((hdr = mime_hdr_find(headers, "content-type")) == NULL + || hdr->value == NULL) { sk_MIME_HEADER_pop_free(headers, mime_hdr_free); ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_NO_CONTENT_TYPE); return NULL; @@ -459,7 +461,7 @@ /* Parse the signature piece */ asnin = sk_BIO_value(parts, 1); - if (!(headers = mime_parse_hdr(asnin))) { + if ((headers = mime_parse_hdr(asnin)) == NULL) { ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_MIME_SIG_PARSE_ERROR); sk_BIO_pop_free(parts, BIO_vfree); return NULL; @@ -467,7 +469,8 @@ /* Get content type */ - if (!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) { + if ((hdr = mime_hdr_find(headers, "content-type")) == NULL + || hdr->value == NULL) { sk_MIME_HEADER_pop_free(headers, mime_hdr_free); ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_NO_SIG_CONTENT_TYPE); return NULL; @@ -483,7 +486,7 @@ } sk_MIME_HEADER_pop_free(headers, mime_hdr_free); /* Read in ASN1 */ - if (!(val = b64_read_asn1(asnin, it))) { + if ((val = b64_read_asn1(asnin, it)) == NULL) { ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_ASN1_SIG_PARSE_ERROR); sk_BIO_pop_free(parts, BIO_vfree); return NULL; @@ -510,7 +513,7 @@ sk_MIME_HEADER_pop_free(headers, mime_hdr_free); - if (!(val = b64_read_asn1(bio, it))) { + if ((val = b64_read_asn1(bio, it)) == NULL) { ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_ASN1_PARSE_ERROR); return NULL; } @@ -573,11 +576,12 @@ STACK_OF(MIME_HEADER) *headers; MIME_HEADER *hdr; - if (!(headers = mime_parse_hdr(in))) { + if ((headers = mime_parse_hdr(in)) == NULL) { ASN1err(ASN1_F_SMIME_TEXT, ASN1_R_MIME_PARSE_ERROR); return 0; } - if (!(hdr = mime_hdr_find(headers, "content-type")) || !hdr->value) { + if ((hdr = mime_hdr_find(headers, "content-type")) == NULL + || hdr->value == NULL) { ASN1err(ASN1_F_SMIME_TEXT, ASN1_R_MIME_NO_CONTENT_TYPE); sk_MIME_HEADER_pop_free(headers, mime_hdr_free); return 0; @@ -822,8 +826,9 @@ MIME_HEADER *mhdr = NULL; char *tmpname = NULL, *tmpval = NULL, *p; int c; + if (name) { - if (!(tmpname = BUF_strdup(name))) + if ((tmpname = BUF_strdup(name)) == NULL) return NULL; for (p = tmpname; *p; p++) { c = (unsigned char)*p; @@ -834,7 +839,7 @@ } } if (value) { - if (!(tmpval = BUF_strdup(value))) + if ((tmpval = BUF_strdup(value)) == NULL) goto err; for (p = tmpval; *p; p++) { c = (unsigned char)*p; @@ -849,7 +854,7 @@ goto err; mhdr->name = tmpname; mhdr->value = tmpval; - if (!(mhdr->params = sk_MIME_PARAM_new(mime_param_cmp))) + if ((mhdr->params = sk_MIME_PARAM_new(mime_param_cmp)) == NULL) goto err; return mhdr;
diff --git a/crypto/asn1/asn_moid.c b/crypto/asn1/asn_moid.c index da7e291..9459bb2 100644 --- a/crypto/asn1/asn_moid.c +++ b/crypto/asn1/asn_moid.c
@@ -76,8 +76,9 @@ const char *oid_section; STACK_OF(CONF_VALUE) *sktmp; CONF_VALUE *oval; + oid_section = CONF_imodule_get_value(md); - if (!(sktmp = NCONF_get_section(cnf, oid_section))) { + if ((sktmp = NCONF_get_section(cnf, oid_section)) == NULL) { ASN1err(ASN1_F_OID_MODULE_INIT, ASN1_R_ERROR_LOADING_SECTION); return 0; }
diff --git a/crypto/asn1/asn_mstbl.c b/crypto/asn1/asn_mstbl.c index 9b50d14..a2e80b1 100644 --- a/crypto/asn1/asn_mstbl.c +++ b/crypto/asn1/asn_mstbl.c
@@ -70,8 +70,9 @@ const char *stbl_section; STACK_OF(CONF_VALUE) *sktmp; CONF_VALUE *mval; + stbl_section = CONF_imodule_get_value(md); - if (!(sktmp = NCONF_get_section(cnf, stbl_section))) { + if ((sktmp = NCONF_get_section(cnf, stbl_section)) == NULL) { ASN1err(ASN1_F_STBL_MODULE_INIT, ASN1_R_ERROR_LOADING_SECTION); return 0; }
diff --git a/crypto/asn1/asn_pack.c b/crypto/asn1/asn_pack.c index e358a86..b80016b 100644 --- a/crypto/asn1/asn_pack.c +++ b/crypto/asn1/asn_pack.c
@@ -67,8 +67,8 @@ { ASN1_STRING *octmp; - if (!oct || !*oct) { - if (!(octmp = ASN1_STRING_new())) { + if (oct == NULL|| *oct== NULL) { + if ((octmp = ASN1_STRING_new()) == NULL) { ASN1err(ASN1_F_ASN1_ITEM_PACK, ERR_R_MALLOC_FAILURE); return NULL; } @@ -80,7 +80,7 @@ OPENSSL_free(octmp->data); octmp->data = NULL; - if (!(octmp->length = ASN1_item_i2d(obj, &octmp->data, it))) { + if ((octmp->length = ASN1_item_i2d(obj, &octmp->data, it)) == 0) { ASN1err(ASN1_F_ASN1_ITEM_PACK, ASN1_R_ENCODE_ERROR); return NULL; } @@ -99,7 +99,7 @@ void *ret; p = oct->data; - if (!(ret = ASN1_item_d2i(NULL, &p, oct->length, it))) + if ((ret = ASN1_item_d2i(NULL, &p, oct->length, it)) == NULL) ASN1err(ASN1_F_ASN1_ITEM_UNPACK, ASN1_R_DECODE_ERROR); return ret; }
diff --git a/crypto/asn1/p5_pbev2.c b/crypto/asn1/p5_pbev2.c index 4b9045e..c7a1240 100644 --- a/crypto/asn1/p5_pbev2.c +++ b/crypto/asn1/p5_pbev2.c
@@ -106,14 +106,13 @@ } obj = OBJ_nid2obj(alg_nid); - if (!(pbe2 = PBE2PARAM_new())) + if ((pbe2 = PBE2PARAM_new()) == NULL) goto merr; /* Setup the AlgorithmIdentifier for the encryption scheme */ scheme = pbe2->encryption; - scheme->algorithm = obj; - if (!(scheme->parameter = ASN1_TYPE_new())) + if ((scheme->parameter = ASN1_TYPE_new()) == NULL) goto merr; /* Create random IV */ @@ -163,7 +162,7 @@ /* Now set up top level AlgorithmIdentifier */ - if (!(ret = X509_ALGOR_new())) + if ((ret = X509_ALGOR_new()) == NULL) goto merr; ret->algorithm = OBJ_nid2obj(NID_pbes2); @@ -205,17 +204,17 @@ PBKDF2PARAM *kdf = NULL; ASN1_OCTET_STRING *osalt = NULL; - if (!(kdf = PBKDF2PARAM_new())) + if ((kdf = PBKDF2PARAM_new()) == NULL) goto merr; - if (!(osalt = ASN1_OCTET_STRING_new())) + if ((osalt = ASN1_OCTET_STRING_new()) == NULL) goto merr; kdf->salt->value.octet_string = osalt; kdf->salt->type = V_ASN1_OCTET_STRING; - if (!saltlen) + if (saltlen == 0) saltlen = PKCS5_SALT_LEN; - if (!(osalt->data = OPENSSL_malloc(saltlen))) + if ((osalt->data = OPENSSL_malloc(saltlen)) == NULL) goto merr; osalt->length = saltlen; @@ -234,7 +233,7 @@ /* If have a key len set it up */ if (keylen > 0) { - if (!(kdf->keylength = ASN1_INTEGER_new())) + if ((kdf->keylength = ASN1_INTEGER_new()) == NULL) goto merr; if (!ASN1_INTEGER_set(kdf->keylength, keylen)) goto merr;
diff --git a/crypto/asn1/x_x509a.c b/crypto/asn1/x_x509a.c index 775e46f..b0a6b4a 100644 --- a/crypto/asn1/x_x509a.c +++ b/crypto/asn1/x_x509a.c
@@ -84,9 +84,9 @@ static X509_CERT_AUX *aux_get(X509 *x) { - if (!x) + if (x == NULL) return NULL; - if (!x->aux && !(x->aux = X509_CERT_AUX_new())) + if (x->aux == NULL && (x->aux = X509_CERT_AUX_new()) == NULL) return NULL; return x->aux; } @@ -101,9 +101,9 @@ x->aux->alias = NULL; return 1; } - if (!(aux = aux_get(x))) + if ((aux = aux_get(x)) == NULL) return 0; - if (!aux->alias && !(aux->alias = ASN1_UTF8STRING_new())) + if (aux->alias == NULL && (aux->alias = ASN1_UTF8STRING_new()) == NULL) return 0; return ASN1_STRING_set(aux->alias, name, len); } @@ -118,9 +118,10 @@ x->aux->keyid = NULL; return 1; } - if (!(aux = aux_get(x))) + if ((aux = aux_get(x)) == NULL) return 0; - if (!aux->keyid && !(aux->keyid = ASN1_OCTET_STRING_new())) + if (aux->keyid ==NULL + && (aux->keyid = ASN1_OCTET_STRING_new()) == NULL) return 0; return ASN1_STRING_set(aux->keyid, id, len); } @@ -152,9 +153,10 @@ if (!objtmp) return 0; } - if (!(aux = aux_get(x))) + if ((aux = aux_get(x)) == NULL) goto err; - if (!aux->trust && !(aux->trust = sk_ASN1_OBJECT_new_null())) + if (aux->trust == NULL + && (aux->trust = sk_ASN1_OBJECT_new_null()) == NULL) goto err; if (!objtmp || sk_ASN1_OBJECT_push(aux->trust, objtmp)) return 1; @@ -167,11 +169,12 @@ { X509_CERT_AUX *aux; ASN1_OBJECT *objtmp; - if (!(objtmp = OBJ_dup(obj))) + if ((objtmp = OBJ_dup(obj)) == NULL) return 0; - if (!(aux = aux_get(x))) + if ((aux = aux_get(x)) == NULL) return 0; - if (!aux->reject && !(aux->reject = sk_ASN1_OBJECT_new_null())) + if (aux->reject == NULL + && (aux->reject = sk_ASN1_OBJECT_new_null()) == NULL) return 0; return sk_ASN1_OBJECT_push(aux->reject, objtmp); }
diff --git a/crypto/bio/bf_nbio.c b/crypto/bio/bf_nbio.c index 53829dd..dc98c4f 100644 --- a/crypto/bio/bf_nbio.c +++ b/crypto/bio/bf_nbio.c
@@ -102,7 +102,7 @@ { NBIO_TEST *nt; - if (!(nt = OPENSSL_malloc(sizeof(*nt)))) + if ((nt = OPENSSL_malloc(sizeof(*nt))) == NULL) return (0); nt->lrn = -1; nt->lwn = -1;
diff --git a/crypto/bio/bss_conn.c b/crypto/bio/bss_conn.c index 60f58e2..9b2cee4 100644 --- a/crypto/bio/bss_conn.c +++ b/crypto/bio/bss_conn.c
@@ -269,7 +269,7 @@ } if (cb != NULL) { - if (!(ret = cb((BIO *)b, c->state, ret))) + if ((ret = cb((BIO *)b, c->state, ret)) == 0) goto end; } }
diff --git a/crypto/bio/bss_dgram.c b/crypto/bio/bss_dgram.c index 53d8136..268481c 100644 --- a/crypto/bio/bss_dgram.c +++ b/crypto/bio/bss_dgram.c
@@ -1406,7 +1406,7 @@ if (data->save_shutdown && !BIO_dgram_sctp_wait_for_dry(b)) { char *tmp; data->saved_message.bio = b; - if (!(tmp = OPENSSL_malloc(inl))) { + if ((tmp = OPENSSL_malloc(inl)) == NULL) { BIOerr(BIO_F_DGRAM_SCTP_WRITE, ERR_R_MALLOC_FAILURE); return -1; }
diff --git a/crypto/bio/bss_mem.c b/crypto/bio/bss_mem.c index 56e0d2e..c55344d 100644 --- a/crypto/bio/bss_mem.c +++ b/crypto/bio/bss_mem.c
@@ -97,12 +97,12 @@ BUF_MEM *b; size_t sz; - if (!buf) { + if (buf == NULL) { BIOerr(BIO_F_BIO_NEW_MEM_BUF, BIO_R_NULL_PARAMETER); return NULL; } sz = (len < 0) ? strlen(buf) : (size_t)len; - if (!(ret = BIO_new(BIO_s_mem()))) + if ((ret = BIO_new(BIO_s_mem())) == NULL) return NULL; b = (BUF_MEM *)ret->ptr; b->data = buf;
diff --git a/crypto/cms/cms_smime.c b/crypto/cms/cms_smime.c index d19ec6d..c161973 100644 --- a/crypto/cms/cms_smime.c +++ b/crypto/cms/cms_smime.c
@@ -801,7 +801,8 @@ { BIO *cmsbio; int ret = 0; - if (!(cmsbio = CMS_dataInit(cms, dcont))) { + + if ((cmsbio = CMS_dataInit(cms, dcont)) == NULL) { CMSerr(CMS_F_CMS_FINAL, ERR_R_MALLOC_FAILURE); return 0; }
diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c index 8af2ab1..ee71f48 100644 --- a/crypto/conf/conf_def.c +++ b/crypto/conf/conf_def.c
@@ -357,7 +357,7 @@ p++; *p = '\0'; - if (!(v = OPENSSL_malloc(sizeof(*v)))) { + if ((v = OPENSSL_malloc(sizeof(*v))) == NULL) { CONFerr(CONF_F_DEF_LOAD_BIO, ERR_R_MALLOC_FAILURE); goto err; }
diff --git a/crypto/conf/conf_lib.c b/crypto/conf/conf_lib.c index 29e77c7..838a645 100644 --- a/crypto/conf/conf_lib.c +++ b/crypto/conf/conf_lib.c
@@ -118,7 +118,7 @@ { BIO *btmp; LHASH_OF(CONF_VALUE) *ltmp; - if (!(btmp = BIO_new_fp(fp, BIO_NOCLOSE))) { + if ((btmp = BIO_new_fp(fp, BIO_NOCLOSE)) == NULL) { CONFerr(CONF_F_CONF_LOAD_FP, ERR_R_BUF_LIB); return NULL; } @@ -200,7 +200,7 @@ BIO *btmp; int ret; - if (!(btmp = BIO_new_fp(out, BIO_NOCLOSE))) { + if ((btmp = BIO_new_fp(out, BIO_NOCLOSE)) == NULL) { CONFerr(CONF_F_CONF_DUMP_FP, ERR_R_BUF_LIB); return 0; } @@ -270,7 +270,7 @@ { BIO *btmp; int ret; - if (!(btmp = BIO_new_fp(fp, BIO_NOCLOSE))) { + if ((btmp = BIO_new_fp(fp, BIO_NOCLOSE)) == NULL) { CONFerr(CONF_F_NCONF_LOAD_FP, ERR_R_BUF_LIB); return 0; } @@ -354,7 +354,7 @@ { BIO *btmp; int ret; - if (!(btmp = BIO_new_fp(out, BIO_NOCLOSE))) { + if ((btmp = BIO_new_fp(out, BIO_NOCLOSE)) == NULL) { CONFerr(CONF_F_NCONF_DUMP_FP, ERR_R_BUF_LIB); return 0; }
diff --git a/crypto/dh/dh_ameth.c b/crypto/dh/dh_ameth.c index b45173e..065f8b9 100644 --- a/crypto/dh/dh_ameth.c +++ b/crypto/dh/dh_ameth.c
@@ -119,18 +119,18 @@ pm = pstr->data; pmlen = pstr->length; - if (!(dh = d2i_dhp(pkey, &pm, pmlen))) { + if ((dh = d2i_dhp(pkey, &pm, pmlen)) == NULL) { DHerr(DH_F_DH_PUB_DECODE, DH_R_DECODE_ERROR); goto err; } - if (!(public_key = d2i_ASN1_INTEGER(NULL, &p, pklen))) { + if ((public_key = d2i_ASN1_INTEGER(NULL, &p, pklen)) == NULL) { DHerr(DH_F_DH_PUB_DECODE, DH_R_DECODE_ERROR); goto err; } /* We have parameters now set public key */ - if (!(dh->pub_key = ASN1_INTEGER_to_BN(public_key, NULL))) { + if ((dh->pub_key = ASN1_INTEGER_to_BN(public_key, NULL)) == NULL) { DHerr(DH_F_DH_PUB_DECODE, DH_R_BN_DECODE_ERROR); goto err; } @@ -218,17 +218,17 @@ if (ptype != V_ASN1_SEQUENCE) goto decerr; - - if (!(privkey = d2i_ASN1_INTEGER(NULL, &p, pklen))) + if ((privkey = d2i_ASN1_INTEGER(NULL, &p, pklen)) == NULL) goto decerr; pstr = pval; pm = pstr->data; pmlen = pstr->length; - if (!(dh = d2i_dhp(pkey, &pm, pmlen))) + if ((dh = d2i_dhp(pkey, &pm, pmlen)) == NULL) goto decerr; + /* We have parameters now set private key */ - if (!(dh->priv_key = ASN1_INTEGER_to_BN(privkey, NULL))) { + if ((dh->priv_key = ASN1_INTEGER_to_BN(privkey, NULL)) == NULL) { DHerr(DH_F_DH_PRIV_DECODE, DH_R_BN_ERROR); goto dherr; } @@ -310,7 +310,8 @@ const unsigned char **pder, int derlen) { DH *dh; - if (!(dh = d2i_dhp(pkey, pder, derlen))) { + + if ((dh = d2i_dhp(pkey, pder, derlen)) == NULL) { DHerr(DH_F_DH_PARAM_DECODE, ERR_R_DH_LIB); return 0; } @@ -679,13 +680,13 @@ if (!p || !plen) goto err; - if (!(public_key = d2i_ASN1_INTEGER(NULL, &p, plen))) { + if ((public_key = d2i_ASN1_INTEGER(NULL, &p, plen)) == NULL) { DHerr(DH_F_DH_CMS_SET_PEERKEY, DH_R_DECODE_ERROR); goto err; } /* We have parameters now set public key */ - if (!(dhpeer->pub_key = ASN1_INTEGER_to_BN(public_key, NULL))) { + if ((dhpeer->pub_key = ASN1_INTEGER_to_BN(public_key, NULL)) == NULL) { DHerr(DH_F_DH_CMS_SET_PEERKEY, DH_R_BN_DECODE_ERROR); goto err; }
diff --git a/crypto/dsa/dsa_ameth.c b/crypto/dsa/dsa_ameth.c index e5009ec..bc8fcc4 100644 --- a/crypto/dsa/dsa_ameth.c +++ b/crypto/dsa/dsa_ameth.c
@@ -88,13 +88,13 @@ pm = pstr->data; pmlen = pstr->length; - if (!(dsa = d2i_DSAparams(NULL, &pm, pmlen))) { + if ((dsa = d2i_DSAparams(NULL, &pm, pmlen)) == NULL) { DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_DECODE_ERROR); goto err; } } else if ((ptype == V_ASN1_NULL) || (ptype == V_ASN1_UNDEF)) { - if (!(dsa = DSA_new())) { + if ((dsa = DSA_new()) == NULL) { DSAerr(DSA_F_DSA_PUB_DECODE, ERR_R_MALLOC_FAILURE); goto err; } @@ -103,12 +103,12 @@ goto err; } - if (!(public_key = d2i_ASN1_INTEGER(NULL, &p, pklen))) { + if ((public_key = d2i_ASN1_INTEGER(NULL, &p, pklen)) == NULL) { DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_DECODE_ERROR); goto err; } - if (!(dsa->pub_key = ASN1_INTEGER_to_BN(public_key, NULL))) { + if ((dsa->pub_key = ASN1_INTEGER_to_BN(public_key, NULL)) == NULL) { DSAerr(DSA_F_DSA_PUB_DECODE, DSA_R_BN_DECODE_ERROR); goto err; } @@ -201,7 +201,7 @@ /* Check for broken DSA PKCS#8, UGH! */ if (*p == (V_ASN1_SEQUENCE | V_ASN1_CONSTRUCTED)) { ASN1_TYPE *t1, *t2; - if (!(ndsa = d2i_ASN1_SEQUENCE_ANY(NULL, &p, pklen))) + if ((ndsa = d2i_ASN1_SEQUENCE_ANY(NULL, &p, pklen)) == NULL) goto decerr; if (sk_ASN1_TYPE_num(ndsa) != 2) goto decerr; @@ -227,12 +227,12 @@ privkey = t2->value.integer; } else { const unsigned char *q = p; - if (!(privkey = d2i_ASN1_INTEGER(NULL, &p, pklen))) + if ((privkey = d2i_ASN1_INTEGER(NULL, &p, pklen)) == NULL) goto decerr; if (privkey->type == V_ASN1_NEG_INTEGER) { p8->broken = PKCS8_NEG_PRIVKEY; ASN1_STRING_clear_free(privkey); - if (!(privkey = d2i_ASN1_UINTEGER(NULL, &q, pklen))) + if ((privkey = d2i_ASN1_UINTEGER(NULL, &q, pklen)) == NULL) goto decerr; } if (ptype != V_ASN1_SEQUENCE) @@ -242,19 +242,19 @@ pstr = pval; pm = pstr->data; pmlen = pstr->length; - if (!(dsa = d2i_DSAparams(NULL, &pm, pmlen))) + if ((dsa = d2i_DSAparams(NULL, &pm, pmlen)) == NULL) goto decerr; /* We have parameters now set private key */ - if (!(dsa->priv_key = ASN1_INTEGER_to_BN(privkey, NULL))) { + if ((dsa->priv_key = ASN1_INTEGER_to_BN(privkey, NULL)) == NULL) { DSAerr(DSA_F_DSA_PRIV_DECODE, DSA_R_BN_ERROR); goto dsaerr; } /* Calculate public key */ - if (!(dsa->pub_key = BN_new())) { + if ((dsa->pub_key = BN_new()) == NULL) { DSAerr(DSA_F_DSA_PRIV_DECODE, ERR_R_MALLOC_FAILURE); goto dsaerr; } - if (!(ctx = BN_CTX_new())) { + if ((ctx = BN_CTX_new()) == NULL) { DSAerr(DSA_F_DSA_PRIV_DECODE, ERR_R_MALLOC_FAILURE); goto dsaerr; } @@ -477,7 +477,8 @@ const unsigned char **pder, int derlen) { DSA *dsa; - if (!(dsa = d2i_DSAparams(NULL, pder, derlen))) { + + if ((dsa = d2i_DSAparams(NULL, pder, derlen)) == NULL) { DSAerr(DSA_F_DSA_PARAM_DECODE, ERR_R_DSA_LIB); return 0; } @@ -512,7 +513,8 @@ const unsigned char **pder, int derlen) { DSA *dsa; - if (!(dsa = d2i_DSAPrivateKey(NULL, pder, derlen))) { + + if ((dsa = d2i_DSAPrivateKey(NULL, pder, derlen)) == NULL) { DSAerr(DSA_F_OLD_DSA_PRIV_DECODE, ERR_R_DSA_LIB); return 0; }
diff --git a/crypto/ec/ec_ameth.c b/crypto/ec/ec_ameth.c index 1cc4d40..268eff0 100644 --- a/crypto/ec/ec_ameth.c +++ b/crypto/ec/ec_ameth.c
@@ -145,7 +145,7 @@ int pmlen; pm = pstr->data; pmlen = pstr->length; - if (!(eckey = d2i_ECParameters(NULL, &pm, pmlen))) { + if ((eckey = d2i_ECParameters(NULL, &pm, pmlen)) == NULL) { ECerr(EC_F_ECKEY_TYPE2PARAM, EC_R_DECODE_ERROR); goto ecerr; } @@ -510,7 +510,8 @@ const unsigned char **pder, int derlen) { EC_KEY *eckey; - if (!(eckey = d2i_ECParameters(NULL, pder, derlen))) { + + if ((eckey = d2i_ECParameters(NULL, pder, derlen)) == NULL) { ECerr(EC_F_ECKEY_PARAM_DECODE, ERR_R_EC_LIB); return 0; } @@ -545,7 +546,8 @@ const unsigned char **pder, int derlen) { EC_KEY *ec; - if (!(ec = d2i_ECPrivateKey(NULL, pder, derlen))) { + + if ((ec = d2i_ECPrivateKey(NULL, pder, derlen)) == NULL) { ECerr(EC_F_OLD_EC_PRIV_DECODE, EC_R_DECODE_ERROR); return 0; }
diff --git a/crypto/ec/ec_asn1.c b/crypto/ec/ec_asn1.c index 638f849..ebafc10 100644 --- a/crypto/ec/ec_asn1.c +++ b/crypto/ec/ec_asn1.c
@@ -838,7 +838,7 @@ /* extract seed (optional) */ if (params->curve->seed != NULL) { OPENSSL_free(ret->seed); - if (!(ret->seed = OPENSSL_malloc(params->curve->seed->length))) { + if ((ret->seed = OPENSSL_malloc(params->curve->seed->length)) == NULL) { ECerr(EC_F_EC_ASN1_PARAMETERS2GROUP, ERR_R_MALLOC_FAILURE); goto err; }
diff --git a/crypto/ec/ec_curve.c b/crypto/ec/ec_curve.c index 8f9308d..f42fe3a 100644 --- a/crypto/ec/ec_curve.c +++ b/crypto/ec/ec_curve.c
@@ -3049,9 +3049,9 @@ params = (const unsigned char *)(data + 1); /* skip header */ params += seed_len; /* skip seed */ - if (!(p = BN_bin2bn(params + 0 * param_len, param_len, NULL)) - || !(a = BN_bin2bn(params + 1 * param_len, param_len, NULL)) - || !(b = BN_bin2bn(params + 2 * param_len, param_len, NULL))) { + if ((p = BN_bin2bn(params + 0 * param_len, param_len, NULL)) == NULL + || (a = BN_bin2bn(params + 1 * param_len, param_len, NULL)) == NULL + || (b = BN_bin2bn(params + 2 * param_len, param_len, NULL)) == NULL) { ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB); goto err; } @@ -3085,8 +3085,8 @@ goto err; } - if (!(x = BN_bin2bn(params + 3 * param_len, param_len, NULL)) - || !(y = BN_bin2bn(params + 4 * param_len, param_len, NULL))) { + if ((x = BN_bin2bn(params + 3 * param_len, param_len, NULL)) == NULL + || (y = BN_bin2bn(params + 4 * param_len, param_len, NULL)) == NULL) { ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB); goto err; } @@ -3094,7 +3094,7 @@ ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); goto err; } - if (!(order = BN_bin2bn(params + 5 * param_len, param_len, NULL)) + if ((order = BN_bin2bn(params + 5 * param_len, param_len, NULL)) == NULL || !BN_set_word(x, (BN_ULONG)data->cofactor)) { ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB); goto err;
diff --git a/crypto/ec/ec_mult.c b/crypto/ec/ec_mult.c index 9b75b9b..09f042e 100644 --- a/crypto/ec/ec_mult.c +++ b/crypto/ec/ec_mult.c
@@ -465,7 +465,7 @@ goto err; } - if (!(tmp = EC_POINT_new(group))) + if ((tmp = EC_POINT_new(group)) == NULL) goto err; /*- @@ -674,7 +674,8 @@ } } - if (!(tmp_point = EC_POINT_new(group)) || !(base = EC_POINT_new(group))) { + if ((tmp_point = EC_POINT_new(group)) == NULL + || (base = EC_POINT_new(group)) == NULL) { ECerr(EC_F_EC_WNAF_PRECOMPUTE_MULT, ERR_R_MALLOC_FAILURE); goto err; }
diff --git a/crypto/ec/ec_pmeth.c b/crypto/ec/ec_pmeth.c index 37d3efb..42e3d3a 100644 --- a/crypto/ec/ec_pmeth.c +++ b/crypto/ec/ec_pmeth.c
@@ -427,7 +427,7 @@ return EVP_PKEY_CTX_set_ec_param_enc(ctx, param_enc); } else if (strcmp(type, "ecdh_kdf_md") == 0) { const EVP_MD *md; - if (!(md = EVP_get_digestbyname(value))) { + if ((md = EVP_get_digestbyname(value)) == NULL) { ECerr(EC_F_PKEY_EC_CTRL_STR, EC_R_INVALID_DIGEST); return 0; }
diff --git a/crypto/evp/evp_cnf.c b/crypto/evp/evp_cnf.c index 3073091..11ee56a 100644 --- a/crypto/evp/evp_cnf.c +++ b/crypto/evp/evp_cnf.c
@@ -74,8 +74,9 @@ const char *oid_section; STACK_OF(CONF_VALUE) *sktmp; CONF_VALUE *oval; + oid_section = CONF_imodule_get_value(md); - if (!(sktmp = NCONF_get_section(cnf, oid_section))) { + if ((sktmp = NCONF_get_section(cnf, oid_section)) == NULL) { EVPerr(EVP_F_ALG_MODULE_INIT, EVP_R_ERROR_LOADING_SECTION); return 0; }
diff --git a/crypto/evp/evp_pbe.c b/crypto/evp/evp_pbe.c index 0f32507..63b3ad1 100644 --- a/crypto/evp/evp_pbe.c +++ b/crypto/evp/evp_pbe.c
@@ -227,9 +227,9 @@ { EVP_PBE_CTL *pbe_tmp; - if (!pbe_algs) + if (pbe_algs == NULL) pbe_algs = sk_EVP_PBE_CTL_new(pbe_cmp); - if (!(pbe_tmp = OPENSSL_malloc(sizeof(*pbe_tmp)))) { + if ((pbe_tmp = OPENSSL_malloc(sizeof(*pbe_tmp))) == NULL) { EVPerr(EVP_F_EVP_PBE_ALG_ADD_TYPE, ERR_R_MALLOC_FAILURE); return 0; } @@ -247,6 +247,7 @@ EVP_PBE_KEYGEN *keygen) { int cipher_nid, md_nid; + if (cipher) cipher_nid = EVP_CIPHER_nid(cipher); else
diff --git a/crypto/evp/evp_pkey.c b/crypto/evp/evp_pkey.c index 7e64e26..e987c4c 100644 --- a/crypto/evp/evp_pkey.c +++ b/crypto/evp/evp_pkey.c
@@ -75,7 +75,7 @@ if (!PKCS8_pkey_get0(&algoid, NULL, NULL, NULL, p8)) return NULL; - if (!(pkey = EVP_PKEY_new())) { + if ((pkey = EVP_PKEY_new()) == NULL) { EVPerr(EVP_F_EVP_PKCS82PKEY, ERR_R_MALLOC_FAILURE); return NULL; } @@ -115,7 +115,7 @@ { PKCS8_PRIV_KEY_INFO *p8; - if (!(p8 = PKCS8_PRIV_KEY_INFO_new())) { + if ((p8 = PKCS8_PRIV_KEY_INFO_new()) == NULL) { EVPerr(EVP_F_EVP_PKEY2PKCS8_BROKEN, ERR_R_MALLOC_FAILURE); return NULL; }
diff --git a/crypto/evp/pmeth_lib.c b/crypto/evp/pmeth_lib.c index 10d9746..fef0b8f 100644 --- a/crypto/evp/pmeth_lib.c +++ b/crypto/evp/pmeth_lib.c
@@ -416,7 +416,7 @@ } if (strcmp(name, "digest") == 0) { const EVP_MD *md; - if (!value || !(md = EVP_get_digestbyname(value))) { + if (value == NULL || (md = EVP_get_digestbyname(value)) == NULL) { EVPerr(EVP_F_EVP_PKEY_CTX_CTRL_STR, EVP_R_INVALID_DIGEST); return 0; }
diff --git a/crypto/objects/obj_dat.c b/crypto/objects/obj_dat.c index 82af4a4..991a1b7 100644 --- a/crypto/objects/obj_dat.c +++ b/crypto/objects/obj_dat.c
@@ -255,16 +255,16 @@ return (0); if ((o = OBJ_dup(obj)) == NULL) goto err; - if (!(ao[ADDED_NID] = OPENSSL_malloc(sizeof(*ao)))) + if ((ao[ADDED_NID] = OPENSSL_malloc(sizeof(*ao))) == NULL) goto err2; if ((o->length != 0) && (obj->data != NULL)) - if (!(ao[ADDED_DATA] = OPENSSL_malloc(sizeof(*ao)))) + if ((ao[ADDED_DATA] = OPENSSL_malloc(sizeof(*ao))) == NULL) goto err2; if (o->sn != NULL) - if (!(ao[ADDED_SNAME] = OPENSSL_malloc(sizeof(*ao)))) + if ((ao[ADDED_SNAME] = OPENSSL_malloc(sizeof(*ao))) == NULL) goto err2; if (o->ln != NULL) - if (!(ao[ADDED_LNAME] = OPENSSL_malloc(sizeof(*ao)))) + if ((ao[ADDED_LNAME] = OPENSSL_malloc(sizeof(*ao))) == NULL) goto err2; for (i = ADDED_DATA; i <= ADDED_NID; i++) { @@ -507,7 +507,7 @@ if (!(c & 0x80)) break; if (!use_bn && (l > (ULONG_MAX >> 7L))) { - if (!bl && !(bl = BN_new())) + if (bl == NULL && (bl = BN_new()) == NULL) goto err; if (!BN_set_word(bl, l)) goto err;
diff --git a/crypto/ocsp/ocsp_cl.c b/crypto/ocsp/ocsp_cl.c index 0f3f13f..b6ec19a 100644 --- a/crypto/ocsp/ocsp_cl.c +++ b/crypto/ocsp/ocsp_cl.c
@@ -89,7 +89,7 @@ { OCSP_ONEREQ *one = NULL; - if (!(one = OCSP_ONEREQ_new())) + if ((one = OCSP_ONEREQ_new()) == NULL) goto err; OCSP_CERTID_free(one->reqCert); one->reqCert = cid; @@ -132,7 +132,8 @@ return 0; if (!cert) return 1; - if (!sig->certs && !(sig->certs = sk_X509_new_null())) + if (sig->certs == NULL + && (sig->certs = sk_X509_new_null()) == NULL) return 0; if (!sk_X509_push(sig->certs, cert)) @@ -159,7 +160,7 @@ if (!OCSP_request_set1_name(req, X509_get_subject_name(signer))) goto err; - if (!(req->optionalSignature = OCSP_SIGNATURE_new())) + if ((req->optionalSignature = OCSP_SIGNATURE_new()) == NULL) goto err; if (key) { if (!X509_check_private_key(signer, key)) {
diff --git a/crypto/ocsp/ocsp_ext.c b/crypto/ocsp/ocsp_ext.c index 8a35f75..63a8332 100644 --- a/crypto/ocsp/ocsp_ext.c +++ b/crypto/ocsp/ocsp_ext.c
@@ -415,22 +415,22 @@ X509_EXTENSION *x = NULL; OCSP_CRLID *cid = NULL; - if (!(cid = OCSP_CRLID_new())) + if ((cid = OCSP_CRLID_new()) == NULL) goto err; if (url) { - if (!(cid->crlUrl = ASN1_IA5STRING_new())) + if ((cid->crlUrl = ASN1_IA5STRING_new()) == NULL) goto err; if (!(ASN1_STRING_set(cid->crlUrl, url, -1))) goto err; } if (n) { - if (!(cid->crlNum = ASN1_INTEGER_new())) + if ((cid->crlNum = ASN1_INTEGER_new()) == NULL) goto err; if (!(ASN1_INTEGER_set(cid->crlNum, *n))) goto err; } if (tim) { - if (!(cid->crlTime = ASN1_GENERALIZEDTIME_new())) + if ((cid->crlTime = ASN1_GENERALIZEDTIME_new()) == NULL) goto err; if (!(ASN1_GENERALIZEDTIME_set_string(cid->crlTime, tim))) goto err; @@ -449,7 +449,7 @@ ASN1_OBJECT *o = NULL; X509_EXTENSION *x = NULL; - if (!(sk = sk_ASN1_OBJECT_new_null())) + if ((sk = sk_ASN1_OBJECT_new_null()) == NULL) goto err; while (oids && *oids) { if ((nid = OBJ_txt2nid(*oids)) != NID_undef && (o = OBJ_nid2obj(nid))) @@ -468,7 +468,7 @@ X509_EXTENSION *x = NULL; ASN1_GENERALIZEDTIME *gt = NULL; - if (!(gt = ASN1_GENERALIZEDTIME_new())) + if ((gt = ASN1_GENERALIZEDTIME_new()) == NULL) goto err; if (!(ASN1_GENERALIZEDTIME_set_string(gt, tim))) goto err; @@ -490,20 +490,21 @@ OCSP_SERVICELOC *sloc = NULL; ACCESS_DESCRIPTION *ad = NULL; - if (!(sloc = OCSP_SERVICELOC_new())) + if ((sloc = OCSP_SERVICELOC_new()) == NULL) goto err; - if (!(sloc->issuer = X509_NAME_dup(issuer))) + if ((sloc->issuer = X509_NAME_dup(issuer)) == NULL) goto err; - if (urls && *urls && !(sloc->locator = sk_ACCESS_DESCRIPTION_new_null())) + if (urls && *urls + && (sloc->locator = sk_ACCESS_DESCRIPTION_new_null()) == NULL) goto err; while (urls && *urls) { - if (!(ad = ACCESS_DESCRIPTION_new())) + if ((ad = ACCESS_DESCRIPTION_new()) == NULL) goto err; - if (!(ad->method = OBJ_nid2obj(NID_ad_OCSP))) + if ((ad->method = OBJ_nid2obj(NID_ad_OCSP)) == NULL) goto err; - if (!(ad->location = GENERAL_NAME_new())) + if ((ad->location = GENERAL_NAME_new()) == NULL) goto err; - if (!(ia5 = ASN1_IA5STRING_new())) + if ((ia5 = ASN1_IA5STRING_new()) == NULL) goto err; if (!ASN1_STRING_set((ASN1_STRING *)ia5, *urls, -1)) goto err;
diff --git a/crypto/ocsp/ocsp_lib.c b/crypto/ocsp/ocsp_lib.c index 1f383f6..b0e7122 100644 --- a/crypto/ocsp/ocsp_lib.c +++ b/crypto/ocsp/ocsp_lib.c
@@ -106,7 +106,7 @@ OCSP_CERTID *cid = NULL; unsigned char md[EVP_MAX_MD_SIZE]; - if (!(cid = OCSP_CERTID_new())) + if ((cid = OCSP_CERTID_new()) == NULL) goto err; alg = cid->hashAlgorithm; @@ -115,7 +115,7 @@ OCSPerr(OCSP_F_OCSP_CERT_ID_NEW, OCSP_R_UNKNOWN_NID); goto err; } - if (!(alg->algorithm = OBJ_nid2obj(nid))) + if ((alg->algorithm = OBJ_nid2obj(nid)) == NULL) goto err; if ((alg->parameter = ASN1_TYPE_new()) == NULL) goto err; @@ -135,7 +135,7 @@ if (serialNumber) { ASN1_INTEGER_free(cid->serialNumber); - if (!(cid->serialNumber = ASN1_INTEGER_dup(serialNumber))) + if ((cid->serialNumber = ASN1_INTEGER_dup(serialNumber)) == NULL) goto err; } return cid;
diff --git a/crypto/ocsp/ocsp_prn.c b/crypto/ocsp/ocsp_prn.c index 96c2023..b826292 100644 --- a/crypto/ocsp/ocsp_prn.c +++ b/crypto/ocsp/ocsp_prn.c
@@ -214,7 +214,7 @@ } i = ASN1_STRING_length(rb->response); - if (!(br = OCSP_response_get1_basic(o))) + if ((br = OCSP_response_get1_basic(o)) == NULL) goto err; rd = br->tbsResponseData; l = ASN1_INTEGER_get(rd->version);
diff --git a/crypto/ocsp/ocsp_srv.c b/crypto/ocsp/ocsp_srv.c index 1afa68c..3b71dd7 100644 --- a/crypto/ocsp/ocsp_srv.c +++ b/crypto/ocsp/ocsp_srv.c
@@ -116,13 +116,13 @@ { OCSP_RESPONSE *rsp = NULL; - if (!(rsp = OCSP_RESPONSE_new())) + if ((rsp = OCSP_RESPONSE_new()) == NULL) goto err; if (!(ASN1_ENUMERATED_set(rsp->responseStatus, status))) goto err; if (!bs) return rsp; - if (!(rsp->responseBytes = OCSP_RESPBYTES_new())) + if ((rsp->responseBytes = OCSP_RESPBYTES_new()) == NULL) goto err; rsp->responseBytes->responseType = OBJ_nid2obj(NID_id_pkix_OCSP_basic); if (!ASN1_item_pack @@ -145,11 +145,12 @@ OCSP_CERTSTATUS *cs; OCSP_REVOKEDINFO *ri; - if (!rsp->tbsResponseData->responses && - !(rsp->tbsResponseData->responses = sk_OCSP_SINGLERESP_new_null())) + if (rsp->tbsResponseData->responses == NULL + && (rsp->tbsResponseData->responses + = sk_OCSP_SINGLERESP_new_null()) == NULL) goto err; - if (!(single = OCSP_SINGLERESP_new())) + if ((single = OCSP_SINGLERESP_new()) == NULL) goto err; if (!ASN1_TIME_to_generalizedtime(thisupd, &single->thisUpdate)) @@ -160,7 +161,7 @@ OCSP_CERTID_free(single->certId); - if (!(single->certId = OCSP_CERTID_dup(cid))) + if ((single->certId = OCSP_CERTID_dup(cid)) == NULL) goto err; cs = single->certStatus; @@ -170,12 +171,12 @@ OCSPerr(OCSP_F_OCSP_BASIC_ADD1_STATUS, OCSP_R_NO_REVOKED_TIME); goto err; } - if (!(cs->value.revoked = ri = OCSP_REVOKEDINFO_new())) + if ((cs->value.revoked = ri = OCSP_REVOKEDINFO_new()) == NULL) goto err; if (!ASN1_TIME_to_generalizedtime(revtime, &ri->revocationTime)) goto err; if (reason != OCSP_REVOKED_STATUS_NOSTATUS) { - if (!(ri->revocationReason = ASN1_ENUMERATED_new())) + if ((ri->revocationReason = ASN1_ENUMERATED_new()) == NULL) goto err; if (!(ASN1_ENUMERATED_set(ri->revocationReason, reason))) goto err; @@ -206,7 +207,8 @@ int OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert) { - if (!resp->certs && !(resp->certs = sk_X509_new_null())) + if (resp->certs == NULL + && (resp->certs = sk_X509_new_null()) == NULL) return 0; if (!sk_X509_push(resp->certs, cert)) @@ -242,7 +244,7 @@ if (flags & OCSP_RESPID_KEY) { unsigned char md[SHA_DIGEST_LENGTH]; X509_pubkey_digest(signer, EVP_sha1(), md, NULL); - if (!(rid->value.byKey = ASN1_OCTET_STRING_new())) + if ((rid->value.byKey = ASN1_OCTET_STRING_new()) == NULL) goto err; if (!(ASN1_OCTET_STRING_set(rid->value.byKey, md, SHA_DIGEST_LENGTH))) goto err;
diff --git a/crypto/ocsp/ocsp_vfy.c b/crypto/ocsp/ocsp_vfy.c index 9bf1ff5..d2693c7 100644 --- a/crypto/ocsp/ocsp_vfy.c +++ b/crypto/ocsp/ocsp_vfy.c
@@ -314,7 +314,8 @@ X509_NAME *iname; int mdlen; unsigned char md[EVP_MAX_MD_SIZE]; - if (!(dgst = EVP_get_digestbyobj(cid->hashAlgorithm->algorithm))) { + if ((dgst = EVP_get_digestbyobj(cid->hashAlgorithm->algorithm)) + == NULL) { OCSPerr(OCSP_F_OCSP_MATCH_ISSUERID, OCSP_R_UNKNOWN_MESSAGE_DIGEST); return -1;
diff --git a/crypto/pem/pem_pk8.c b/crypto/pem/pem_pk8.c index 529d077..52b40fe 100644 --- a/crypto/pem/pem_pk8.c +++ b/crypto/pem/pem_pk8.c
@@ -116,7 +116,8 @@ PKCS8_PRIV_KEY_INFO *p8inf; char buf[PEM_BUFSIZE]; int ret; - if (!(p8inf = EVP_PKEY2PKCS8(x))) { + + if ((p8inf = EVP_PKEY2PKCS8(x)) == NULL) { PEMerr(PEM_F_DO_PK8PKEY, PEM_R_ERROR_CONVERTING_PRIVATE_KEY); return 0; } @@ -224,7 +225,8 @@ { BIO *bp; int ret; - if (!(bp = BIO_new_fp(fp, BIO_NOCLOSE))) { + + if ((bp = BIO_new_fp(fp, BIO_NOCLOSE)) == NULL) { PEMerr(PEM_F_DO_PK8PKEY_FP, ERR_R_BUF_LIB); return (0); } @@ -238,7 +240,8 @@ { BIO *bp; EVP_PKEY *ret; - if (!(bp = BIO_new_fp(fp, BIO_NOCLOSE))) { + + if ((bp = BIO_new_fp(fp, BIO_NOCLOSE)) == NULL) { PEMerr(PEM_F_D2I_PKCS8PRIVATEKEY_FP, ERR_R_BUF_LIB); return NULL; }
diff --git a/crypto/pem/pvkfmt.c b/crypto/pem/pvkfmt.c index d2a5952..0900ef6 100644 --- a/crypto/pem/pvkfmt.c +++ b/crypto/pem/pvkfmt.c
@@ -316,13 +316,12 @@ if (!read_lebn(&p, 20, &dsa->priv_key)) goto memerr; /* Calculate public key */ - if (!(dsa->pub_key = BN_new())) + if ((dsa->pub_key = BN_new()) == NULL) goto memerr; - if (!(ctx = BN_CTX_new())) + if ((ctx = BN_CTX_new()) == NULL) goto memerr; if (!BN_mod_exp(dsa->pub_key, dsa->g, dsa->priv_key, dsa->p, ctx)) - goto memerr; BN_CTX_free(ctx); }
diff --git a/crypto/pkcs12/p12_add.c b/crypto/pkcs12/p12_add.c index 51ea42a..301fed6 100644 --- a/crypto/pkcs12/p12_add.c +++ b/crypto/pkcs12/p12_add.c
@@ -68,7 +68,8 @@ { PKCS12_BAGS *bag; PKCS12_SAFEBAG *safebag; - if (!(bag = PKCS12_BAGS_new())) { + + if ((bag = PKCS12_BAGS_new()) == NULL) { PKCS12err(PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG, ERR_R_MALLOC_FAILURE); return NULL; } @@ -77,7 +78,7 @@ PKCS12err(PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG, ERR_R_MALLOC_FAILURE); return NULL; } - if (!(safebag = PKCS12_SAFEBAG_new())) { + if ((safebag = PKCS12_SAFEBAG_new()) == NULL) { PKCS12err(PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG, ERR_R_MALLOC_FAILURE); return NULL; } @@ -91,7 +92,8 @@ PKCS12_SAFEBAG *PKCS12_MAKE_KEYBAG(PKCS8_PRIV_KEY_INFO *p8) { PKCS12_SAFEBAG *bag; - if (!(bag = PKCS12_SAFEBAG_new())) { + + if ((bag = PKCS12_SAFEBAG_new()) == NULL) { PKCS12err(PKCS12_F_PKCS12_MAKE_KEYBAG, ERR_R_MALLOC_FAILURE); return NULL; } @@ -111,7 +113,7 @@ const EVP_CIPHER *pbe_ciph; /* Set up the safe bag */ - if (!(bag = PKCS12_SAFEBAG_new())) { + if ((bag = PKCS12_SAFEBAG_new()) == NULL) { PKCS12err(PKCS12_F_PKCS12_MAKE_SHKEYBAG, ERR_R_MALLOC_FAILURE); return NULL; } @@ -137,12 +139,13 @@ PKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk) { PKCS7 *p7; - if (!(p7 = PKCS7_new())) { + + if ((p7 = PKCS7_new()) == NULL) { PKCS12err(PKCS12_F_PKCS12_PACK_P7DATA, ERR_R_MALLOC_FAILURE); return NULL; } p7->type = OBJ_nid2obj(NID_pkcs7_data); - if (!(p7->d.data = ASN1_OCTET_STRING_new())) { + if ((p7->d.data = ASN1_OCTET_STRING_new()) == NULL) { PKCS12err(PKCS12_F_PKCS12_PACK_P7DATA, ERR_R_MALLOC_FAILURE); return NULL; } @@ -174,7 +177,8 @@ PKCS7 *p7; X509_ALGOR *pbe; const EVP_CIPHER *pbe_ciph; - if (!(p7 = PKCS7_new())) { + + if ((p7 = PKCS7_new()) == NULL) { PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE); return NULL; }
diff --git a/crypto/pkcs12/p12_attr.c b/crypto/pkcs12/p12_attr.c index 70695b7..365a1cd 100644 --- a/crypto/pkcs12/p12_attr.c +++ b/crypto/pkcs12/p12_attr.c
@@ -129,7 +129,8 @@ char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag) { ASN1_TYPE *atype; - if (!(atype = PKCS12_get_attr(bag, NID_friendlyName))) + + if ((atype = PKCS12_get_attr(bag, NID_friendlyName)) == NULL) return NULL; if (atype->type != V_ASN1_BMPSTRING) return NULL;
diff --git a/crypto/pkcs12/p12_crt.c b/crypto/pkcs12/p12_crt.c index fcc77cd..cc25410 100644 --- a/crypto/pkcs12/p12_crt.c +++ b/crypto/pkcs12/p12_crt.c
@@ -189,7 +189,7 @@ int keyidlen = -1; /* Add user certificate */ - if (!(bag = PKCS12_x5092certbag(cert))) + if ((bag = PKCS12_x5092certbag(cert)) == NULL) goto err; /* @@ -226,7 +226,7 @@ PKCS8_PRIV_KEY_INFO *p8 = NULL; /* Make a PKCS#8 structure */ - if (!(p8 = EVP_PKEY2PKCS8(key))) + if ((p8 = EVP_PKEY2PKCS8(key)) == NULL) goto err; if (key_usage && !PKCS8_add_keyusage(p8, key_usage)) goto err;
diff --git a/crypto/pkcs12/p12_decr.c b/crypto/pkcs12/p12_decr.c index 19efd96..5154e54 100644 --- a/crypto/pkcs12/p12_decr.c +++ b/crypto/pkcs12/p12_decr.c
@@ -88,7 +88,8 @@ return NULL; } - if (!(out = OPENSSL_malloc(inlen + EVP_CIPHER_CTX_block_size(&ctx)))) { + if ((out = OPENSSL_malloc(inlen + EVP_CIPHER_CTX_block_size(&ctx))) + == NULL) { PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT, ERR_R_MALLOC_FAILURE); goto err; } @@ -174,7 +175,8 @@ ASN1_OCTET_STRING *oct = NULL; unsigned char *in = NULL; int inlen; - if (!(oct = ASN1_OCTET_STRING_new())) { + + if ((oct = ASN1_OCTET_STRING_new()) == NULL) { PKCS12err(PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT, ERR_R_MALLOC_FAILURE); goto err; }
diff --git a/crypto/pkcs12/p12_init.c b/crypto/pkcs12/p12_init.c index 22fa10e..29f9831 100644 --- a/crypto/pkcs12/p12_init.c +++ b/crypto/pkcs12/p12_init.c
@@ -66,7 +66,8 @@ PKCS12 *PKCS12_init(int mode) { PKCS12 *pkcs12; - if (!(pkcs12 = PKCS12_new())) { + + if ((pkcs12 = PKCS12_new()) == NULL) { PKCS12err(PKCS12_F_PKCS12_INIT, ERR_R_MALLOC_FAILURE); return NULL; } @@ -74,7 +75,7 @@ pkcs12->authsafes->type = OBJ_nid2obj(mode); switch (mode) { case NID_pkcs7_data: - if (!(pkcs12->authsafes->d.data = ASN1_OCTET_STRING_new())) { + if ((pkcs12->authsafes->d.data = ASN1_OCTET_STRING_new()) == NULL) { PKCS12err(PKCS12_F_PKCS12_INIT, ERR_R_MALLOC_FAILURE); goto err; }
diff --git a/crypto/pkcs12/p12_kiss.c b/crypto/pkcs12/p12_kiss.c index cd18427..a2dbc42 100644 --- a/crypto/pkcs12/p12_kiss.c +++ b/crypto/pkcs12/p12_kiss.c
@@ -179,7 +179,7 @@ int i, bagnid; PKCS7 *p7; - if (!(asafes = PKCS12_unpack_authsafes(p12))) + if ((asafes = PKCS12_unpack_authsafes(p12)) == NULL) return 0; for (i = 0; i < sk_PKCS7_num(asafes); i++) { p7 = sk_PKCS7_value(asafes, i); @@ -236,14 +236,14 @@ case NID_keyBag: if (!pkey || *pkey) return 1; - if (!(*pkey = EVP_PKCS82PKEY(bag->value.keybag))) + if ((*pkey = EVP_PKCS82PKEY(bag->value.keybag)) == NULL) return 0; break; case NID_pkcs8ShroudedKeyBag: if (!pkey || *pkey) return 1; - if (!(p8 = PKCS12_decrypt_skey(bag, pass, passlen))) + if ((p8 = PKCS12_decrypt_skey(bag, pass, passlen)) == NULL) return 0; *pkey = EVP_PKCS82PKEY(p8); PKCS8_PRIV_KEY_INFO_free(p8); @@ -254,7 +254,7 @@ case NID_certBag: if (M_PKCS12_cert_bag_type(bag) != NID_x509Certificate) return 1; - if (!(x509 = PKCS12_certbag2x509(bag))) + if ((x509 = PKCS12_certbag2x509(bag)) == NULL) return 0; if (lkid && !X509_keyid_set1(x509, lkid->data, lkid->length)) { X509_free(x509);
diff --git a/crypto/pkcs12/p12_mutl.c b/crypto/pkcs12/p12_mutl.c index 252aca0..b193da1 100644 --- a/crypto/pkcs12/p12_mutl.c +++ b/crypto/pkcs12/p12_mutl.c
@@ -84,7 +84,8 @@ iter = 1; else iter = ASN1_INTEGER_get(p12->mac->iter); - if (!(md_type = EVP_get_digestbyobj(p12->mac->dinfo->algor->algorithm))) { + if ((md_type = EVP_get_digestbyobj(p12->mac->dinfo->algor->algorithm)) + == NULL) { PKCS12err(PKCS12_F_PKCS12_GEN_MAC, PKCS12_R_UNKNOWN_DIGEST_ALGORITHM); return 0; } @@ -157,10 +158,10 @@ int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, int saltlen, const EVP_MD *md_type) { - if (!(p12->mac = PKCS12_MAC_DATA_new())) + if ((p12->mac = PKCS12_MAC_DATA_new()) == NULL) return PKCS12_ERROR; if (iter > 1) { - if (!(p12->mac->iter = ASN1_INTEGER_new())) { + if ((p12->mac->iter = ASN1_INTEGER_new()) == NULL) { PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE); return 0; } @@ -172,7 +173,7 @@ if (!saltlen) saltlen = PKCS12_SALT_LEN; p12->mac->salt->length = saltlen; - if (!(p12->mac->salt->data = OPENSSL_malloc(saltlen))) { + if ((p12->mac->salt->data = OPENSSL_malloc(saltlen)) == NULL) { PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE); return 0; } @@ -182,7 +183,7 @@ } else memcpy(p12->mac->salt->data, salt, saltlen); p12->mac->dinfo->algor->algorithm = OBJ_nid2obj(EVP_MD_type(md_type)); - if (!(p12->mac->dinfo->algor->parameter = ASN1_TYPE_new())) { + if ((p12->mac->dinfo->algor->parameter = ASN1_TYPE_new()) == NULL) { PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE); return 0; }
diff --git a/crypto/pkcs12/p12_npas.c b/crypto/pkcs12/p12_npas.c index f756033..c402428 100644 --- a/crypto/pkcs12/p12_npas.c +++ b/crypto/pkcs12/p12_npas.c
@@ -113,9 +113,9 @@ unsigned char mac[EVP_MAX_MD_SIZE]; unsigned int maclen; - if (!(asafes = PKCS12_unpack_authsafes(p12))) + if ((asafes = PKCS12_unpack_authsafes(p12)) == NULL) return 0; - if (!(newsafes = sk_PKCS7_new_null())) + if ((newsafes = sk_PKCS7_new_null()) == NULL) return 0; for (i = 0; i < sk_PKCS7_num(asafes); i++) { p7 = sk_PKCS7_value(asafes, i); @@ -158,14 +158,14 @@ /* Repack safe: save old safe in case of error */ p12_data_tmp = p12->authsafes->d.data; - if (!(p12->authsafes->d.data = ASN1_OCTET_STRING_new())) + if ((p12->authsafes->d.data = ASN1_OCTET_STRING_new()) == NULL) goto saferr; if (!PKCS12_pack_authsafes(p12, newsafes)) goto saferr; if (!PKCS12_gen_mac(p12, newpass, -1, mac, &maclen)) goto saferr; - if (!(macnew = ASN1_OCTET_STRING_new())) + if ((macnew = ASN1_OCTET_STRING_new()) == NULL) goto saferr; if (!ASN1_OCTET_STRING_set(macnew, mac, maclen)) goto saferr; @@ -206,12 +206,12 @@ if (M_PKCS12_bag_type(bag) != NID_pkcs8ShroudedKeyBag) return 1; - if (!(p8 = PKCS8_decrypt(bag->value.shkeybag, oldpass, -1))) + if ((p8 = PKCS8_decrypt(bag->value.shkeybag, oldpass, -1)) == NULL) return 0; if (!alg_get(bag->value.shkeybag->algor, &p8_nid, &p8_iter, &p8_saltlen)) return 0; - if (!(p8new = PKCS8_encrypt(p8_nid, NULL, newpass, -1, NULL, p8_saltlen, - p8_iter, p8))) + if ((p8new = PKCS8_encrypt(p8_nid, NULL, newpass, -1, NULL, p8_saltlen, + p8_iter, p8)) == NULL) return 0; X509_SIG_free(bag->value.shkeybag); bag->value.shkeybag = p8new;
diff --git a/crypto/pkcs12/p12_p8e.c b/crypto/pkcs12/p12_p8e.c index 0275742..9375cbf 100644 --- a/crypto/pkcs12/p12_p8e.c +++ b/crypto/pkcs12/p12_p8e.c
@@ -66,10 +66,10 @@ unsigned char *salt, int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8inf) { - X509_SIG *p8 = NULL; + X509_SIG *p8; X509_ALGOR *pbe; - if (!(p8 = X509_SIG_new())) { + if ((p8 = X509_SIG_new()) == NULL) { PKCS12err(PKCS12_F_PKCS8_ENCRYPT, ERR_R_MALLOC_FAILURE); goto err; }
diff --git a/crypto/pkcs12/p12_utl.c b/crypto/pkcs12/p12_utl.c index 4546815..c55a4f1 100644 --- a/crypto/pkcs12/p12_utl.c +++ b/crypto/pkcs12/p12_utl.c
@@ -68,10 +68,11 @@ { int ulen, i; unsigned char *unitmp; + if (asclen == -1) asclen = strlen(asc); ulen = asclen * 2 + 2; - if (!(unitmp = OPENSSL_malloc(ulen))) + if ((unitmp = OPENSSL_malloc(ulen)) == NULL) return NULL; for (i = 0; i < ulen - 2; i += 2) { unitmp[i] = 0; @@ -91,12 +92,13 @@ { int asclen, i; char *asctmp; + asclen = unilen / 2; /* If no terminating zero allow for one */ if (!unilen || uni[unilen - 1]) asclen++; uni++; - if (!(asctmp = OPENSSL_malloc(asclen))) + if ((asctmp = OPENSSL_malloc(asclen)) == NULL) return NULL; for (i = 0; i < unilen; i += 2) asctmp[i >> 1] = uni[i];
diff --git a/crypto/pkcs7/pk7_attr.c b/crypto/pkcs7/pk7_attr.c index 88922ef..ef2386b 100644 --- a/crypto/pkcs7/pk7_attr.c +++ b/crypto/pkcs7/pk7_attr.c
@@ -71,7 +71,8 @@ STACK_OF(X509_ALGOR) *cap) { ASN1_STRING *seq; - if (!(seq = ASN1_STRING_new())) { + + if ((seq = ASN1_STRING_new()) == NULL) { PKCS7err(PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP, ERR_R_MALLOC_FAILURE); return 0; } @@ -87,7 +88,7 @@ const unsigned char *p; cap = PKCS7_get_signed_attribute(si, NID_SMIMECapabilities); - if (!cap || (cap->type != V_ASN1_SEQUENCE)) + if (cap == NULL || (cap->type != V_ASN1_SEQUENCE)) return NULL; p = cap->value.sequence->data; return (STACK_OF(X509_ALGOR) *) @@ -100,7 +101,7 @@ { X509_ALGOR *alg; - if (!(alg = X509_ALGOR_new())) { + if ((alg = X509_ALGOR_new()) == NULL) { PKCS7err(PKCS7_F_PKCS7_SIMPLE_SMIMECAP, ERR_R_MALLOC_FAILURE); return 0; } @@ -108,11 +109,11 @@ alg->algorithm = OBJ_nid2obj(nid); if (arg > 0) { ASN1_INTEGER *nbit; - if (!(alg->parameter = ASN1_TYPE_new())) { + if ((alg->parameter = ASN1_TYPE_new()) == NULL) { PKCS7err(PKCS7_F_PKCS7_SIMPLE_SMIMECAP, ERR_R_MALLOC_FAILURE); return 0; } - if (!(nbit = ASN1_INTEGER_new())) { + if ((nbit = ASN1_INTEGER_new()) == NULL) { PKCS7err(PKCS7_F_PKCS7_SIMPLE_SMIMECAP, ERR_R_MALLOC_FAILURE); return 0; } @@ -139,7 +140,7 @@ int PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t) { - if (!t && !(t = X509_gmtime_adj(NULL, 0))) { + if (t == NULL && (t = X509_gmtime_adj(NULL, 0)) == NULL) { PKCS7err(PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME, ERR_R_MALLOC_FAILURE); return 0;
diff --git a/crypto/pkcs7/pk7_doit.c b/crypto/pkcs7/pk7_doit.c index e5ad95f..bdbde21 100644 --- a/crypto/pkcs7/pk7_doit.c +++ b/crypto/pkcs7/pk7_doit.c
@@ -1104,7 +1104,7 @@ ASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk) { ASN1_TYPE *astype; - if (!(astype = get_attribute(sk, NID_pkcs9_messageDigest))) + if ((astype = get_attribute(sk, NID_pkcs9_messageDigest)) == NULL) return NULL; return astype->value.octet_string; } @@ -1165,11 +1165,10 @@ X509_ATTRIBUTE *attr = NULL; if (*sk == NULL) { - *sk = sk_X509_ATTRIBUTE_new_null(); - if (*sk == NULL) + if ((*sk = sk_X509_ATTRIBUTE_new_null()) == NULL) return 0; new_attrib: - if (!(attr = X509_ATTRIBUTE_create(nid, atrtype, value))) + if ((attr = X509_ATTRIBUTE_create(nid, atrtype, value)) == NULL) return 0; if (!sk_X509_ATTRIBUTE_push(*sk, attr)) { X509_ATTRIBUTE_free(attr);
diff --git a/crypto/pkcs7/pk7_lib.c b/crypto/pkcs7/pk7_lib.c index e14d8c6..30cc98f 100644 --- a/crypto/pkcs7/pk7_lib.c +++ b/crypto/pkcs7/pk7_lib.c
@@ -265,8 +265,8 @@ } } if (!j) { /* we need to add another algorithm */ - if (!(alg = X509_ALGOR_new()) - || !(alg->parameter = ASN1_TYPE_new())) { + if ((alg = X509_ALGOR_new()) == NULL + || (alg->parameter = ASN1_TYPE_new()) == NULL) { X509_ALGOR_free(alg); PKCS7err(PKCS7_F_PKCS7_ADD_SIGNER, ERR_R_MALLOC_FAILURE); return (0); @@ -426,7 +426,7 @@ int PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md) { if (PKCS7_type_is_digest(p7)) { - if (!(p7->d.digest->md->parameter = ASN1_TYPE_new())) { + if ((p7->d.digest->md->parameter = ASN1_TYPE_new()) == NULL) { PKCS7err(PKCS7_F_PKCS7_SET_DIGEST, ERR_R_MALLOC_FAILURE); return 0; }
diff --git a/crypto/pkcs7/pk7_smime.c b/crypto/pkcs7/pk7_smime.c index 33bdda2..edc5969 100644 --- a/crypto/pkcs7/pk7_smime.c +++ b/crypto/pkcs7/pk7_smime.c
@@ -72,7 +72,7 @@ PKCS7 *p7; int i; - if (!(p7 = PKCS7_new())) { + if ((p7 = PKCS7_new()) == NULL) { PKCS7err(PKCS7_F_PKCS7_SIGN, ERR_R_MALLOC_FAILURE); return NULL; } @@ -113,7 +113,7 @@ { BIO *p7bio; int ret = 0; - if (!(p7bio = PKCS7_dataInit(p7, NULL))) { + if ((p7bio = PKCS7_dataInit(p7, NULL)) == NULL) { PKCS7err(PKCS7_F_PKCS7_FINAL, ERR_R_MALLOC_FAILURE); return 0; } @@ -164,7 +164,7 @@ return NULL; } - if (!(si = PKCS7_add_signature(p7, signcert, pkey, md))) { + if ((si = PKCS7_add_signature(p7, signcert, pkey, md)) == NULL) { PKCS7err(PKCS7_F_PKCS7_SIGN_ADD_SIGNER, PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR); return NULL; @@ -180,7 +180,7 @@ goto err; /* Add SMIMECapabilities */ if (!(flags & PKCS7_NOSMIMECAP)) { - if (!(smcap = sk_X509_ALGOR_new_null())) { + if ((smcap = sk_X509_ALGOR_new_null()) == NULL) { PKCS7err(PKCS7_F_PKCS7_SIGN_ADD_SIGNER, ERR_R_MALLOC_FAILURE); goto err; } @@ -353,11 +353,11 @@ } else tmpin = indata; - if (!(p7bio = PKCS7_dataInit(p7, tmpin))) + if ((p7bio = PKCS7_dataInit(p7, tmpin)) == NULL) goto err; if (flags & PKCS7_TEXT) { - if (!(tmpout = BIO_new(BIO_s_mem()))) { + if ((tmpout = BIO_new(BIO_s_mem())) == NULL) { PKCS7err(PKCS7_F_PKCS7_VERIFY, ERR_R_MALLOC_FAILURE); goto err; } @@ -439,7 +439,7 @@ return 0; } - if (!(signers = sk_X509_new_null())) { + if ((signers = sk_X509_new_null()) == NULL) { PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS, ERR_R_MALLOC_FAILURE); return NULL; } @@ -481,7 +481,7 @@ BIO *p7bio = NULL; int i; X509 *x509; - if (!(p7 = PKCS7_new())) { + if ((p7 = PKCS7_new()) == NULL) { PKCS7err(PKCS7_F_PKCS7_ENCRYPT, ERR_R_MALLOC_FAILURE); return NULL; } @@ -537,7 +537,7 @@ return 0; } - if (!(tmpmem = PKCS7_dataDecode(p7, pkey, NULL, cert))) { + if ((tmpmem = PKCS7_dataDecode(p7, pkey, NULL, cert)) == NULL) { PKCS7err(PKCS7_F_PKCS7_DECRYPT, PKCS7_R_DECRYPT_ERROR); return 0; } @@ -545,12 +545,12 @@ if (flags & PKCS7_TEXT) { BIO *tmpbuf, *bread; /* Encrypt BIOs can't do BIO_gets() so add a buffer BIO */ - if (!(tmpbuf = BIO_new(BIO_f_buffer()))) { + if ((tmpbuf = BIO_new(BIO_f_buffer())) == NULL) { PKCS7err(PKCS7_F_PKCS7_DECRYPT, ERR_R_MALLOC_FAILURE); BIO_free_all(tmpmem); return 0; } - if (!(bread = BIO_push(tmpbuf, tmpmem))) { + if ((bread = BIO_push(tmpbuf, tmpmem)) == NULL) { PKCS7err(PKCS7_F_PKCS7_DECRYPT, ERR_R_MALLOC_FAILURE); BIO_free_all(tmpbuf); BIO_free_all(tmpmem);
diff --git a/crypto/rsa/rsa_ameth.c b/crypto/rsa/rsa_ameth.c index e9ccd7e..509f203 100644 --- a/crypto/rsa/rsa_ameth.c +++ b/crypto/rsa/rsa_ameth.c
@@ -93,9 +93,10 @@ const unsigned char *p; int pklen; RSA *rsa = NULL; + if (!X509_PUBKEY_get0_param(NULL, &p, &pklen, NULL, pubkey)) return 0; - if (!(rsa = d2i_RSAPublicKey(NULL, &p, pklen))) { + if ((rsa = d2i_RSAPublicKey(NULL, &p, pklen)) == NULL) { RSAerr(RSA_F_RSA_PUB_DECODE, ERR_R_RSA_LIB); return 0; } @@ -115,7 +116,8 @@ const unsigned char **pder, int derlen) { RSA *rsa; - if (!(rsa = d2i_RSAPrivateKey(NULL, pder, derlen))) { + + if ((rsa = d2i_RSAPrivateKey(NULL, pder, derlen)) == NULL) { RSAerr(RSA_F_OLD_RSA_PRIV_DECODE, ERR_R_RSA_LIB); return 0; }
diff --git a/crypto/rsa/rsa_pmeth.c b/crypto/rsa/rsa_pmeth.c index ced7232..76d5c69 100644 --- a/crypto/rsa/rsa_pmeth.c +++ b/crypto/rsa/rsa_pmeth.c
@@ -606,7 +606,7 @@ if (strcmp(type, "rsa_mgf1_md") == 0) { const EVP_MD *md; - if (!(md = EVP_get_digestbyname(value))) { + if ((md = EVP_get_digestbyname(value)) == NULL) { RSAerr(RSA_F_PKEY_RSA_CTRL_STR, RSA_R_INVALID_DIGEST); return 0; } @@ -615,7 +615,7 @@ if (strcmp(type, "rsa_oaep_md") == 0) { const EVP_MD *md; - if (!(md = EVP_get_digestbyname(value))) { + if ((md = EVP_get_digestbyname(value)) == NULL) { RSAerr(RSA_F_PKEY_RSA_CTRL_STR, RSA_R_INVALID_DIGEST); return 0; }
diff --git a/crypto/srp/srp_lib.c b/crypto/srp/srp_lib.c index 7a47acd..1b26319 100644 --- a/crypto/srp/srp_lib.c +++ b/crypto/srp/srp_lib.c
@@ -127,7 +127,7 @@ EVP_DigestFinal_ex(&ctxt, cu, NULL); EVP_MD_CTX_cleanup(&ctxt); - if (!(u = BN_bin2bn(cu, sizeof(cu), NULL))) + if ((u = BN_bin2bn(cu, sizeof(cu), NULL)) == NULL) return NULL; if (!BN_is_zero(u)) return u; @@ -178,10 +178,10 @@ /* B = g**b + k*v */ - if (!BN_mod_exp(gb, g, b, N, bn_ctx) || - !(k = srp_Calc_k(N, g)) || - !BN_mod_mul(kv, v, k, N, bn_ctx) || - !BN_mod_add(B, gb, kv, N, bn_ctx)) { + if (!BN_mod_exp(gb, g, b, N, bn_ctx) + || (k = srp_Calc_k(N, g)) == NULL + || !BN_mod_mul(kv, v, k, N, bn_ctx) + || !BN_mod_add(B, gb, kv, N, bn_ctx)) { BN_free(B); B = NULL; } @@ -257,13 +257,12 @@ if (!BN_mod_exp(tmp, g, x, N, bn_ctx)) goto err; - if (!(k = srp_Calc_k(N, g))) + if ((k = srp_Calc_k(N, g)) == NULL) goto err; if (!BN_mod_mul(tmp2, tmp, k, N, bn_ctx)) goto err; if (!BN_mod_sub(tmp, B, tmp2, N, bn_ctx)) goto err; - if (!BN_mod_mul(tmp3, u, x, N, bn_ctx)) goto err; if (!BN_mod_add(tmp2, a, tmp3, N, bn_ctx))
diff --git a/crypto/srp/srp_vfy.c b/crypto/srp/srp_vfy.c index 075c9ed..79db92a 100644 --- a/crypto/srp/srp_vfy.c +++ b/crypto/srp/srp_vfy.c
@@ -253,8 +253,8 @@ if (vb == NULL) return NULL; - if (!(vb->users_pwd = sk_SRP_user_pwd_new_null()) || - !(vb->gN_cache = sk_SRP_gN_cache_new_null())) { + if ((vb->users_pwd = sk_SRP_user_pwd_new_null()) == NULL + || (vb->gN_cache = sk_SRP_gN_cache_new_null()) == NULL) { OPENSSL_free(vb); return NULL; } @@ -394,10 +394,11 @@ if ((gN = OPENSSL_malloc(sizeof(*gN))) == NULL) goto err; - if (!(gN->id = BUF_strdup(pp[DB_srpid])) - || !(gN->N = - SRP_gN_place_bn(vb->gN_cache, pp[DB_srpverifier])) - || !(gN->g = SRP_gN_place_bn(vb->gN_cache, pp[DB_srpsalt])) + if ((gN->id = BUF_strdup(pp[DB_srpid])) == NULL + || (gN->N = SRP_gN_place_bn(vb->gN_cache, pp[DB_srpverifier])) + == NULL + || (gN->g = SRP_gN_place_bn(vb->gN_cache, pp[DB_srpsalt])) + == NULL || sk_SRP_gN_insert(SRP_gN_tab, gN, 0) == 0) goto err; @@ -533,10 +534,10 @@ goto err; if (N) { - if (!(len = t_fromb64(tmp, N))) + if ((len = t_fromb64(tmp, N)) == 0) goto err; N_bn = BN_bin2bn(tmp, len, NULL); - if (!(len = t_fromb64(tmp, g))) + if ((len = t_fromb64(tmp, g)) == 0) goto err; g_bn = BN_bin2bn(tmp, len, NULL); defgNid = "*"; @@ -555,7 +556,7 @@ s = BN_bin2bn(tmp2, SRP_RANDOM_SALT_LEN, NULL); } else { - if (!(len = t_fromb64(tmp2, *salt))) + if ((len = t_fromb64(tmp2, *salt)) == 0) goto err; s = BN_bin2bn(tmp2, len, NULL); }
diff --git a/crypto/ts/ts_conf.c b/crypto/ts/ts_conf.c index 2b85660..121b60b 100644 --- a/crypto/ts/ts_conf.c +++ b/crypto/ts/ts_conf.c
@@ -114,11 +114,11 @@ STACK_OF(X509_INFO) *allcerts = NULL; int i; - if (!(certs = BIO_new_file(file, "r"))) + if ((certs = BIO_new_file(file, "r")) == NULL) + goto end; + if ((othercerts = sk_X509_new_null()) == NULL) goto end; - if (!(othercerts = sk_X509_new_null())) - goto end; allcerts = PEM_X509_INFO_read_bio(certs, NULL, NULL, NULL); for (i = 0; i < sk_X509_INFO_num(allcerts); i++) { X509_INFO *xi = sk_X509_INFO_value(allcerts, i); @@ -140,7 +140,7 @@ BIO *key = NULL; EVP_PKEY *pkey = NULL; - if (!(key = BIO_new_file(file, "r"))) + if ((key = BIO_new_file(file, "r")) == NULL) goto end; pkey = PEM_read_bio_PrivateKey(key, NULL, NULL, (char *)pass); end: @@ -195,7 +195,7 @@ { int ret = 0; - if (!device) + if (device == NULL) device = NCONF_get_string(conf, section, ENV_CRYPTO_DEVICE); if (device && !TS_CONF_set_default_engine(device)) { @@ -216,8 +216,9 @@ if (strcmp(name, "builtin") == 0) return 1; - if (!(e = ENGINE_by_id(name))) + if ((e = ENGINE_by_id(name)) == NULL) goto err; + /* Enable the use of the NCipher HSM for forked children. */ if (strcmp(name, "chil") == 0) ENGINE_ctrl(e, ENGINE_CTRL_CHIL_SET_FORKCHECK, 1, 0, 0); @@ -241,13 +242,15 @@ { int ret = 0; X509 *cert_obj = NULL; - if (!cert) + + if (cert == NULL) { cert = NCONF_get_string(conf, section, ENV_SIGNER_CERT); - if (!cert) { - TS_CONF_lookup_fail(section, ENV_SIGNER_CERT); - goto err; + if (cert == NULL) { + TS_CONF_lookup_fail(section, ENV_SIGNER_CERT); + goto err; + } } - if (!(cert_obj = TS_CONF_load_cert(cert))) + if ((cert_obj = TS_CONF_load_cert(cert)) == NULL) goto err; if (!TS_RESP_CTX_set_signer_cert(ctx, cert_obj)) goto err; @@ -263,12 +266,13 @@ { int ret = 0; STACK_OF(X509) *certs_obj = NULL; - if (!certs) - certs = NCONF_get_string(conf, section, ENV_CERTS); - /* Certificate chain is optional. */ - if (!certs) - goto end; - if (!(certs_obj = TS_CONF_load_certs(certs))) + + if (certs == NULL) { + /* Certificate chain is optional. */ + if ((certs = NCONF_get_string(conf, section, ENV_CERTS)) == NULL) + goto end; + } + if ((certs_obj = TS_CONF_load_certs(certs)) == NULL) goto err; if (!TS_RESP_CTX_set_certs(ctx, certs_obj)) goto err; @@ -291,7 +295,7 @@ TS_CONF_lookup_fail(section, ENV_SIGNER_KEY); goto err; } - if (!(key_obj = TS_CONF_load_key(key, pass))) + if ((key_obj = TS_CONF_load_key(key, pass)) == NULL) goto err; if (!TS_RESP_CTX_set_signer_key(ctx, key_obj)) goto err; @@ -313,7 +317,7 @@ TS_CONF_lookup_fail(section, ENV_DEFAULT_POLICY); goto err; } - if (!(policy_obj = OBJ_txt2obj(policy, 0))) { + if ((policy_obj = OBJ_txt2obj(policy, 0)) == NULL) { TS_CONF_invalid(section, ENV_DEFAULT_POLICY); goto err; } @@ -331,10 +335,10 @@ int ret = 0; int i; STACK_OF(CONF_VALUE) *list = NULL; - char *policies = NCONF_get_string(conf, section, - ENV_OTHER_POLICIES); + char *policies = NCONF_get_string(conf, section, ENV_OTHER_POLICIES); + /* If no other policy is specified, that's fine. */ - if (policies && !(list = X509V3_parse_list(policies))) { + if (policies && (list = X509V3_parse_list(policies)) == NULL) { TS_CONF_invalid(section, ENV_OTHER_POLICIES); goto err; } @@ -342,7 +346,8 @@ CONF_VALUE *val = sk_CONF_VALUE_value(list, i); const char *extval = val->value ? val->value : val->name; ASN1_OBJECT *objtmp; - if (!(objtmp = OBJ_txt2obj(extval, 0))) { + + if ((objtmp = OBJ_txt2obj(extval, 0)) == NULL) { TS_CONF_invalid(section, ENV_OTHER_POLICIES); goto err; } @@ -363,11 +368,12 @@ int i; STACK_OF(CONF_VALUE) *list = NULL; char *digests = NCONF_get_string(conf, section, ENV_DIGESTS); - if (!digests) { + + if (digests == NULL) { TS_CONF_lookup_fail(section, ENV_DIGESTS); goto err; } - if (!(list = X509V3_parse_list(digests))) { + if ((list = X509V3_parse_list(digests)) == NULL) { TS_CONF_invalid(section, ENV_DIGESTS); goto err; } @@ -379,7 +385,8 @@ CONF_VALUE *val = sk_CONF_VALUE_value(list, i); const char *extval = val->value ? val->value : val->name; const EVP_MD *md; - if (!(md = EVP_get_digestbyname(extval))) { + + if ((md = EVP_get_digestbyname(extval)) == NULL) { TS_CONF_invalid(section, ENV_DIGESTS); goto err; } @@ -401,7 +408,7 @@ STACK_OF(CONF_VALUE) *list = NULL; char *accuracy = NCONF_get_string(conf, section, ENV_ACCURACY); - if (accuracy && !(list = X509V3_parse_list(accuracy))) { + if (accuracy && (list = X509V3_parse_list(accuracy)) == NULL) { TS_CONF_invalid(section, ENV_ACCURACY); goto err; }
diff --git a/crypto/ts/ts_rsp_sign.c b/crypto/ts/ts_rsp_sign.c index 077d03d..b16cf91 100644 --- a/crypto/ts/ts_rsp_sign.c +++ b/crypto/ts/ts_rsp_sign.c
@@ -169,7 +169,7 @@ { TS_RESP_CTX *ctx; - if (!(ctx = OPENSSL_malloc(sizeof(*ctx)))) { + if ((ctx = OPENSSL_malloc(sizeof(*ctx))) == NULL) { TSerr(TS_F_TS_RESP_CTX_NEW, ERR_R_MALLOC_FAILURE); return NULL; } @@ -225,7 +225,7 @@ int TS_RESP_CTX_set_def_policy(TS_RESP_CTX *ctx, ASN1_OBJECT *def_policy) { ASN1_OBJECT_free(ctx->default_policy); - if (!(ctx->default_policy = OBJ_dup(def_policy))) + if ((ctx->default_policy = OBJ_dup(def_policy)) == NULL) goto err; return 1; err: @@ -240,7 +240,7 @@ ctx->certs = NULL; if (!certs) return 1; - if (!(ctx->certs = X509_chain_up_ref(certs))) { + if ((ctx->certs = X509_chain_up_ref(certs)) == NULL) { TSerr(TS_F_TS_RESP_CTX_SET_CERTS, ERR_R_MALLOC_FAILURE); return 0; } @@ -253,9 +253,10 @@ ASN1_OBJECT *copy = NULL; /* Create new policy stack if necessary. */ - if (!ctx->policies && !(ctx->policies = sk_ASN1_OBJECT_new_null())) + if (ctx->policies == NULL + && (ctx->policies = sk_ASN1_OBJECT_new_null()) == NULL) goto err; - if (!(copy = OBJ_dup(policy))) + if ((copy = OBJ_dup(policy)) == NULL) goto err; if (!sk_ASN1_OBJECT_push(ctx->policies, copy)) goto err; @@ -270,7 +271,8 @@ int TS_RESP_CTX_add_md(TS_RESP_CTX *ctx, const EVP_MD *md) { /* Create new md stack if necessary. */ - if (!ctx->mds && !(ctx->mds = sk_EVP_MD_new_null())) + if (ctx->mds == NULL + && (ctx->mds = sk_EVP_MD_new_null()) == NULL) goto err; /* Add the shared md, no copy needed. */ if (!sk_EVP_MD_push(ctx->mds, (EVP_MD *)md)) @@ -295,14 +297,17 @@ { TS_RESP_CTX_accuracy_free(ctx); - if (secs && (!(ctx->seconds = ASN1_INTEGER_new()) - || !ASN1_INTEGER_set(ctx->seconds, secs))) + if (secs + && ((ctx->seconds = ASN1_INTEGER_new()) == NULL + || !ASN1_INTEGER_set(ctx->seconds, secs))) goto err; - if (millis && (!(ctx->millis = ASN1_INTEGER_new()) - || !ASN1_INTEGER_set(ctx->millis, millis))) + if (millis + && ((ctx->millis = ASN1_INTEGER_new()) == NULL + || !ASN1_INTEGER_set(ctx->millis, millis))) goto err; - if (micros && (!(ctx->micros = ASN1_INTEGER_new()) - || !ASN1_INTEGER_set(ctx->micros, micros))) + if (micros + && ((ctx->micros = ASN1_INTEGER_new()) == NULL + || !ASN1_INTEGER_set(ctx->micros, micros))) goto err; return 1; @@ -343,15 +348,16 @@ ASN1_UTF8STRING *utf8_text = NULL; int ret = 0; - if (!(si = TS_STATUS_INFO_new())) + if ((si = TS_STATUS_INFO_new()) == NULL) goto err; if (!ASN1_INTEGER_set(si->status, status)) goto err; if (text) { - if (!(utf8_text = ASN1_UTF8STRING_new()) + if ((utf8_text = ASN1_UTF8STRING_new()) == NULL || !ASN1_STRING_set(utf8_text, text, strlen(text))) goto err; - if (!si->text && !(si->text = sk_ASN1_UTF8STRING_new_null())) + if (si->text == NULL + && (si->text = sk_ASN1_UTF8STRING_new_null()) == NULL) goto err; if (!sk_ASN1_UTF8STRING_push(si->text, utf8_text)) goto err; @@ -384,7 +390,8 @@ int TS_RESP_CTX_add_failure_info(TS_RESP_CTX *ctx, int failure) { TS_STATUS_INFO *si = TS_RESP_get_status_info(ctx->response); - if (!si->failure_info && !(si->failure_info = ASN1_BIT_STRING_new())) + if (si->failure_info == NULL + && (si->failure_info = ASN1_BIT_STRING_new()) == NULL) goto err; if (!ASN1_BIT_STRING_set_bit(si->failure_info, failure, 1)) goto err; @@ -423,13 +430,13 @@ TS_RESP_CTX_init(ctx); /* Creating the response object. */ - if (!(ctx->response = TS_RESP_new())) { + if ((ctx->response = TS_RESP_new()) == NULL) { TSerr(TS_F_TS_RESP_CREATE_RESPONSE, ERR_R_MALLOC_FAILURE); goto end; } /* Parsing DER request. */ - if (!(ctx->request = d2i_TS_REQ_bio(req_bio, NULL))) { + if ((ctx->request = d2i_TS_REQ_bio(req_bio, NULL)) == NULL) { TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION, "Bad request format or " "system error."); TS_RESP_CTX_add_failure_info(ctx, TS_INFO_BAD_DATA_FORMAT); @@ -445,11 +452,11 @@ goto end; /* Checking acceptable policies. */ - if (!(policy = TS_RESP_get_policy(ctx))) + if ((policy = TS_RESP_get_policy(ctx)) == NULL) goto end; /* Creating the TS_TST_INFO object. */ - if (!(ctx->tst_info = TS_RESP_create_tst_info(ctx, policy))) + if ((ctx->tst_info = TS_RESP_create_tst_info(ctx, policy)) == NULL) goto end; /* Processing extensions. */ @@ -602,7 +609,7 @@ const ASN1_INTEGER *nonce; GENERAL_NAME *tsa_name = NULL; - if (!(tst_info = TS_TST_INFO_new())) + if ((tst_info = TS_TST_INFO_new()) == NULL) goto end; if (!TS_TST_INFO_set_version(tst_info, 1)) goto end; @@ -610,19 +617,19 @@ goto end; if (!TS_TST_INFO_set_msg_imprint(tst_info, ctx->request->msg_imprint)) goto end; - if (!(serial = (*ctx->serial_cb) (ctx, ctx->serial_cb_data)) + if ((serial = ctx->serial_cb(ctx, ctx->serial_cb_data)) == NULL || !TS_TST_INFO_set_serial(tst_info, serial)) goto end; - if (!(*ctx->time_cb) (ctx, ctx->time_cb_data, &sec, &usec) - || !(asn1_time = TS_RESP_set_genTime_with_precision(NULL, - sec, usec, - ctx->clock_precision_digits)) + if (!ctx->time_cb(ctx, ctx->time_cb_data, &sec, &usec) + || (asn1_time = + TS_RESP_set_genTime_with_precision(NULL, sec, usec, + ctx->clock_precision_digits)) == NULL || !TS_TST_INFO_set_time(tst_info, asn1_time)) goto end; /* Setting accuracy if needed. */ if ((ctx->seconds || ctx->millis || ctx->micros) - && !(accuracy = TS_ACCURACY_new())) + && (accuracy = TS_ACCURACY_new()) == NULL) goto end; if (ctx->seconds && !TS_ACCURACY_set_seconds(accuracy, ctx->seconds)) @@ -646,7 +653,7 @@ /* Setting TSA name to subject of signer certificate. */ if (ctx->flags & TS_TSA_NAME) { - if (!(tsa_name = GENERAL_NAME_new())) + if ((tsa_name = GENERAL_NAME_new()) == NULL) goto end; tsa_name->type = GEN_DIRNAME; tsa_name->d.dirn = @@ -715,7 +722,7 @@ } /* Create a new PKCS7 signed object. */ - if (!(p7 = PKCS7_new())) { + if ((p7 = PKCS7_new()) == NULL) { TSerr(TS_F_TS_RESP_SIGN, ERR_R_MALLOC_FAILURE); goto err; } @@ -738,8 +745,8 @@ } /* Add a new signer info. */ - if (!(si = PKCS7_add_signature(p7, ctx->signer_cert, - ctx->signer_key, EVP_sha1()))) { + if ((si = PKCS7_add_signature(p7, ctx->signer_cert, + ctx->signer_key, EVP_sha1())) == NULL) { TSerr(TS_F_TS_RESP_SIGN, TS_R_PKCS7_ADD_SIGNATURE_ERROR); goto err; } @@ -757,7 +764,7 @@ * certificate id and optionally the certificate chain. */ certs = ctx->flags & TS_ESS_CERT_ID_CHAIN ? ctx->certs : NULL; - if (!(sc = ESS_SIGNING_CERT_new_init(ctx->signer_cert, certs))) + if ((sc = ESS_SIGNING_CERT_new_init(ctx->signer_cert, certs)) == NULL) goto err; /* Add SigningCertificate signed attribute to the signer info. */ @@ -771,7 +778,7 @@ goto err; /* Add the DER encoded tst_info to the PKCS7 structure. */ - if (!(p7bio = PKCS7_dataInit(p7, NULL))) { + if ((p7bio = PKCS7_dataInit(p7, NULL)) == NULL) { TSerr(TS_F_TS_RESP_SIGN, ERR_R_MALLOC_FAILURE); goto err; } @@ -813,19 +820,20 @@ int i; /* Creating the ESS_CERT_ID stack. */ - if (!(sc = ESS_SIGNING_CERT_new())) + if ((sc = ESS_SIGNING_CERT_new()) == NULL) goto err; - if (!sc->cert_ids && !(sc->cert_ids = sk_ESS_CERT_ID_new_null())) + if (sc->cert_ids == NULL + && (sc->cert_ids = sk_ESS_CERT_ID_new_null()) == NULL) goto err; /* Adding the signing certificate id. */ - if (!(cid = ESS_CERT_ID_new_init(signcert, 0)) + if ((cid = ESS_CERT_ID_new_init(signcert, 0)) == NULL || !sk_ESS_CERT_ID_push(sc->cert_ids, cid)) goto err; /* Adding the certificate chain ids. */ for (i = 0; i < sk_X509_num(certs); ++i) { X509 *cert = sk_X509_value(certs, i); - if (!(cid = ESS_CERT_ID_new_init(cert, 1)) + if ((cid = ESS_CERT_ID_new_init(cert, 1)) == NULL || !sk_ESS_CERT_ID_push(sc->cert_ids, cid)) goto err; } @@ -845,7 +853,7 @@ /* Recompute SHA1 hash of certificate if necessary (side effect). */ X509_check_purpose(cert, -1, 0); - if (!(cid = ESS_CERT_ID_new())) + if ((cid = ESS_CERT_ID_new()) == NULL) goto err; if (!ASN1_OCTET_STRING_set(cid->hash, cert->sha1_hash, sizeof(cert->sha1_hash))) @@ -854,14 +862,14 @@ /* Setting the issuer/serial if requested. */ if (issuer_needed) { /* Creating issuer/serial structure. */ - if (!cid->issuer_serial - && !(cid->issuer_serial = ESS_ISSUER_SERIAL_new())) + if (cid->issuer_serial == NULL + && (cid->issuer_serial = ESS_ISSUER_SERIAL_new()) == NULL) goto err; /* Creating general name from the certificate issuer. */ - if (!(name = GENERAL_NAME_new())) + if ((name = GENERAL_NAME_new()) == NULL) goto err; name->type = GEN_DIRNAME; - if (!(name->d.dirn = X509_NAME_dup(cert->cert_info->issuer))) + if ((name->d.dirn = X509_NAME_dup(cert->cert_info->issuer)) == NULL) goto err; if (!sk_GENERAL_NAME_push(cid->issuer_serial->issuer, name)) goto err; @@ -887,12 +895,12 @@ ASN1_OCTET_STRING *octet_string = NULL; /* Create new encapsulated NID_id_smime_ct_TSTInfo content. */ - if (!(ret = PKCS7_new())) + if ((ret = PKCS7_new()) == NULL) goto err; - if (!(ret->d.other = ASN1_TYPE_new())) + if ((ret->d.other = ASN1_TYPE_new()) == NULL) goto err; ret->type = OBJ_nid2obj(NID_id_smime_ct_TSTInfo); - if (!(octet_string = ASN1_OCTET_STRING_new())) + if ((octet_string = ASN1_OCTET_STRING_new()) == NULL) goto err; ASN1_TYPE_set(ret->d.other, V_ASN1_OCTET_STRING, octet_string); octet_string = NULL; @@ -915,13 +923,13 @@ int len; len = i2d_ESS_SIGNING_CERT(sc, NULL); - if (!(pp = OPENSSL_malloc(len))) { + if ((pp = OPENSSL_malloc(len)) == NULL) { TSerr(TS_F_ESS_ADD_SIGNING_CERT, ERR_R_MALLOC_FAILURE); goto err; } p = pp; i2d_ESS_SIGNING_CERT(sc, &p); - if (!(seq = ASN1_STRING_new()) || !ASN1_STRING_set(seq, pp, len)) { + if ((seq = ASN1_STRING_new()) == NULL || !ASN1_STRING_set(seq, pp, len)) { TSerr(TS_F_ESS_ADD_SIGNING_CERT, ERR_R_MALLOC_FAILURE); goto err; } @@ -950,7 +958,7 @@ if (precision > TS_MAX_CLOCK_PRECISION_DIGITS) goto err; - if (!(tm = gmtime(&time_sec))) + if ((tm = gmtime(&time_sec)) == NULL) goto err; /* @@ -1001,7 +1009,8 @@ *p++ = '\0'; /* Now call OpenSSL to check and set our genTime value */ - if (!asn1_time && !(asn1_time = ASN1_GENERALIZEDTIME_new())) + if (asn1_time == NULL + && (asn1_time = ASN1_GENERALIZEDTIME_new()) == NULL) goto err; if (!ASN1_GENERALIZEDTIME_set_string(asn1_time, genTime_str)) { ASN1_GENERALIZEDTIME_free(asn1_time);
diff --git a/crypto/ts/ts_rsp_verify.c b/crypto/ts/ts_rsp_verify.c index 8381d41..939c65f 100644 --- a/crypto/ts/ts_rsp_verify.c +++ b/crypto/ts/ts_rsp_verify.c
@@ -511,7 +511,7 @@ /* Set the embedded_status_text to the returned description. */ if (sk_ASN1_UTF8STRING_num(info->text) > 0 - && !(embedded_status_text = TS_get_status_text(info->text))) + && (embedded_status_text = TS_get_status_text(info->text)) == NULL) return 0; /* Filling in failure_text with the failure information. */ @@ -558,7 +558,7 @@ length += 1; /* separator character */ } /* Allocate memory (closing '\0' included). */ - if (!(result = OPENSSL_malloc(length))) { + if ((result = OPENSSL_malloc(length)) == NULL) { TSerr(TS_F_TS_GET_STATUS_TEXT, ERR_R_MALLOC_FAILURE); return NULL; } @@ -604,11 +604,11 @@ *imprint = NULL; /* Return the MD algorithm of the response. */ - if (!(*md_alg = X509_ALGOR_dup(md_alg_resp))) + if ((*md_alg = X509_ALGOR_dup(md_alg_resp)) == NULL) goto err; /* Getting the MD object. */ - if (!(md = EVP_get_digestbyobj((*md_alg)->algorithm))) { + if ((md = EVP_get_digestbyobj((*md_alg)->algorithm)) == NULL) { TSerr(TS_F_TS_COMPUTE_IMPRINT, TS_R_UNSUPPORTED_MD_ALGORITHM); goto err; } @@ -618,7 +618,7 @@ if (length < 0) goto err; *imprint_len = length; - if (!(*imprint = OPENSSL_malloc(*imprint_len))) { + if ((*imprint = OPENSSL_malloc(*imprint_len)) == NULL) { TSerr(TS_F_TS_COMPUTE_IMPRINT, ERR_R_MALLOC_FAILURE); goto err; } @@ -708,15 +708,16 @@ /* Check all the alternative names. */ gen_names = X509_get_ext_d2i(signer, NID_subject_alt_name, NULL, &idx); - while (gen_names != NULL - && !(found = TS_find_name(gen_names, tsa_name) >= 0)) { + while (gen_names != NULL) { + found = TS_find_name(gen_names, tsa_name) >= 0; + if (found) + break; /* * Get the next subject alternative name, although there should be no * more than one. */ GENERAL_NAMES_free(gen_names); - gen_names = X509_get_ext_d2i(signer, NID_subject_alt_name, - NULL, &idx); + gen_names = X509_get_ext_d2i(signer, NID_subject_alt_name, NULL, &idx); } GENERAL_NAMES_free(gen_names);
diff --git a/crypto/ts/ts_verify_ctx.c b/crypto/ts/ts_verify_ctx.c index 75bf2df..3c15e66 100644 --- a/crypto/ts/ts_verify_ctx.c +++ b/crypto/ts/ts_verify_ctx.c
@@ -121,7 +121,7 @@ OPENSSL_assert(req != NULL); if (ret) TS_VERIFY_CTX_cleanup(ret); - else if (!(ret = TS_VERIFY_CTX_new())) + else if ((ret = TS_VERIFY_CTX_new()) == NULL) return NULL; /* Setting flags. */ @@ -129,7 +129,7 @@ /* Setting policy. */ if ((policy = TS_REQ_get_policy_id(req)) != NULL) { - if (!(ret->policy = OBJ_dup(policy))) + if ((ret->policy = OBJ_dup(policy)) == NULL) goto err; } else ret->flags &= ~TS_VFY_POLICY; @@ -137,17 +137,17 @@ /* Setting md_alg, imprint and imprint_len. */ imprint = TS_REQ_get_msg_imprint(req); md_alg = TS_MSG_IMPRINT_get_algo(imprint); - if (!(ret->md_alg = X509_ALGOR_dup(md_alg))) + if ((ret->md_alg = X509_ALGOR_dup(md_alg)) == NULL) goto err; msg = TS_MSG_IMPRINT_get_msg(imprint); ret->imprint_len = ASN1_STRING_length(msg); - if (!(ret->imprint = OPENSSL_malloc(ret->imprint_len))) + if ((ret->imprint = OPENSSL_malloc(ret->imprint_len)) == NULL) goto err; memcpy(ret->imprint, ASN1_STRING_data(msg), ret->imprint_len); /* Setting nonce. */ if ((nonce = TS_REQ_get_nonce(req)) != NULL) { - if (!(ret->nonce = ASN1_INTEGER_dup(nonce))) + if ((ret->nonce = ASN1_INTEGER_dup(nonce)) == NULL) goto err; } else ret->flags &= ~TS_VFY_NONCE;
diff --git a/crypto/txt_db/txt_db.c b/crypto/txt_db/txt_db.c index 54c85d2..5134855 100644 --- a/crypto/txt_db/txt_db.c +++ b/crypto/txt_db/txt_db.c
@@ -123,7 +123,7 @@ continue; else { buf->data[offset - 1] = '\0'; /* blat the '\n' */ - if (!(p = OPENSSL_malloc(add + offset))) + if ((p = OPENSSL_malloc(add + offset)) == NULL) goto err; offset = 0; }
diff --git a/crypto/x509/x509_att.c b/crypto/x509/x509_att.c index df49b0b..67f6b8f 100644 --- a/crypto/x509/x509_att.c +++ b/crypto/x509/x509_att.c
@@ -309,7 +309,7 @@ } atype = stmp->type; } else if (len != -1) { - if (!(stmp = ASN1_STRING_type_new(attrtype))) + if ((stmp = ASN1_STRING_type_new(attrtype)) == NULL) goto err; if (!ASN1_STRING_set(stmp, data, len)) goto err; @@ -322,7 +322,7 @@ */ if (attrtype == 0) return 1; - if (!(ttmp = ASN1_TYPE_new())) + if ((ttmp = ASN1_TYPE_new()) == NULL) goto err; if ((len == -1) && !(attrtype & MBSTRING_FLAG)) { if (!ASN1_TYPE_set1(ttmp, attrtype, data))
diff --git a/crypto/x509/x509_trs.c b/crypto/x509/x509_trs.c index 4207f42..7a16542 100644 --- a/crypto/x509/x509_trs.c +++ b/crypto/x509/x509_trs.c
@@ -188,7 +188,7 @@ idx = X509_TRUST_get_by_id(id); /* Need a new entry */ if (idx == -1) { - if (!(trtmp = OPENSSL_malloc(sizeof(*trtmp)))) { + if ((trtmp = OPENSSL_malloc(sizeof(*trtmp))) == NULL) { X509err(X509_F_X509_TRUST_ADD, ERR_R_MALLOC_FAILURE); return 0; } @@ -200,7 +200,7 @@ if (trtmp->flags & X509_TRUST_DYNAMIC_NAME) OPENSSL_free(trtmp->name); /* dup supplied name */ - if (!(trtmp->name = BUF_strdup(name))) { + if ((trtmp->name = BUF_strdup(name)) == NULL) { X509err(X509_F_X509_TRUST_ADD, ERR_R_MALLOC_FAILURE); return 0; } @@ -216,7 +216,8 @@ /* If its a new entry manage the dynamic table */ if (idx == -1) { - if (!trtable && !(trtable = sk_X509_TRUST_new(tr_cmp))) { + if (trtable == NULL + && (trtable = sk_X509_TRUST_new(tr_cmp)) == NULL) { X509err(X509_F_X509_TRUST_ADD, ERR_R_MALLOC_FAILURE); return 0; }
diff --git a/crypto/x509/x509spki.c b/crypto/x509/x509spki.c index fb46d4e..482741a 100644 --- a/crypto/x509/x509spki.c +++ b/crypto/x509/x509spki.c
@@ -85,7 +85,7 @@ NETSCAPE_SPKI *spki; if (len <= 0) len = strlen(str); - if (!(spki_der = OPENSSL_malloc(len + 1))) { + if ((spki_der = OPENSSL_malloc(len + 1)) == NULL) { X509err(X509_F_NETSCAPE_SPKI_B64_DECODE, ERR_R_MALLOC_FAILURE); return NULL; }
diff --git a/crypto/x509v3/pcy_tree.c b/crypto/x509v3/pcy_tree.c index 6b0167b..7b54e5c 100644 --- a/crypto/x509v3/pcy_tree.c +++ b/crypto/x509v3/pcy_tree.c
@@ -532,7 +532,7 @@ * If no anyPolicy node on this this level it can't appear on lower * levels so end search. */ - if (!(anyptr = curr->anyPolicy)) + if ((anyptr = curr->anyPolicy) == NULL) break; curr++; for (j = 0; j < sk_X509_POLICY_NODE_num(curr->nodes); j++) {
diff --git a/crypto/x509v3/v3_akey.c b/crypto/x509v3/v3_akey.c index 652c904..61bc7b3 100644 --- a/crypto/x509v3/v3_akey.c +++ b/crypto/x509v3/v3_akey.c
@@ -177,12 +177,12 @@ } } - if (!(akeyid = AUTHORITY_KEYID_new())) + if ((akeyid = AUTHORITY_KEYID_new()) == NULL) goto err; if (isname) { - if (!(gens = sk_GENERAL_NAME_new_null()) - || !(gen = GENERAL_NAME_new()) + if ((gens = sk_GENERAL_NAME_new_null()) == NULL + || (gen = GENERAL_NAME_new()) == NULL || !sk_GENERAL_NAME_push(gens, gen)) { X509V3err(X509V3_F_V2I_AUTHORITY_KEYID, ERR_R_MALLOC_FAILURE); goto err;
diff --git a/crypto/x509v3/v3_alt.c b/crypto/x509v3/v3_alt.c index c0c63a9..20f9490 100644 --- a/crypto/x509v3/v3_alt.c +++ b/crypto/x509v3/v3_alt.c
@@ -243,7 +243,8 @@ GENERAL_NAMES *gens = NULL; CONF_VALUE *cnf; int i; - if (!(gens = sk_GENERAL_NAME_new_null())) { + + if ((gens = sk_GENERAL_NAME_new_null()) == NULL) { X509V3err(X509V3_F_V2I_ISSUER_ALT, ERR_R_MALLOC_FAILURE); return NULL; } @@ -255,7 +256,7 @@ goto err; } else { GENERAL_NAME *gen; - if (!(gen = v2i_GENERAL_NAME(method, ctx, cnf))) + if ((gen = v2i_GENERAL_NAME(method, ctx, cnf)) == NULL) goto err; sk_GENERAL_NAME_push(gens, gen); } @@ -274,6 +275,7 @@ GENERAL_NAME *gen; X509_EXTENSION *ext; int i; + if (ctx && (ctx->flags == CTX_TEST)) return 1; if (!ctx || !ctx->issuer_cert) { @@ -283,8 +285,8 @@ i = X509_get_ext_by_NID(ctx->issuer_cert, NID_subject_alt_name, -1); if (i < 0) return 1; - if (!(ext = X509_get_ext(ctx->issuer_cert, i)) || - !(ialt = X509V3_EXT_d2i(ext))) { + if ((ext = X509_get_ext(ctx->issuer_cert, i)) == NULL + || (ialt = X509V3_EXT_d2i(ext)) == NULL) { X509V3err(X509V3_F_COPY_ISSUER, X509V3_R_ISSUER_DECODE_ERROR); goto err; } @@ -312,7 +314,8 @@ GENERAL_NAMES *gens = NULL; CONF_VALUE *cnf; int i; - if (!(gens = sk_GENERAL_NAME_new_null())) { + + if ((gens = sk_GENERAL_NAME_new_null()) == NULL) { X509V3err(X509V3_F_V2I_SUBJECT_ALT, ERR_R_MALLOC_FAILURE); return NULL; } @@ -328,7 +331,7 @@ goto err; } else { GENERAL_NAME *gen; - if (!(gen = v2i_GENERAL_NAME(method, ctx, cnf))) + if ((gen = v2i_GENERAL_NAME(method, ctx, cnf)) == NULL) goto err; sk_GENERAL_NAME_push(gens, gen); } @@ -373,7 +376,7 @@ X509_NAME_ENTRY_free(ne); i--; } - if (!email || !(gen = GENERAL_NAME_new())) { + if (email == NULL || (gen = GENERAL_NAME_new()) == NULL) { X509V3err(X509V3_F_COPY_EMAIL, ERR_R_MALLOC_FAILURE); goto err; } @@ -403,13 +406,14 @@ GENERAL_NAMES *gens = NULL; CONF_VALUE *cnf; int i; - if (!(gens = sk_GENERAL_NAME_new_null())) { + + if ((gens = sk_GENERAL_NAME_new_null()) == NULL) { X509V3err(X509V3_F_V2I_GENERAL_NAMES, ERR_R_MALLOC_FAILURE); return NULL; } for (i = 0; i < sk_CONF_VALUE_num(nval); i++) { cnf = sk_CONF_VALUE_value(nval, i); - if (!(gen = v2i_GENERAL_NAME(method, ctx, cnf))) + if ((gen = v2i_GENERAL_NAME(method, ctx, cnf)) == NULL) goto err; sk_GENERAL_NAME_push(gens, gen); } @@ -458,7 +462,7 @@ case GEN_RID: { ASN1_OBJECT *obj; - if (!(obj = OBJ_txt2obj(value, 0))) { + if ((obj = OBJ_txt2obj(value, 0)) == NULL) { X509V3err(X509V3_F_A2I_GENERAL_NAME, X509V3_R_BAD_OBJECT); ERR_add_error_data(2, "value=", value); goto err; @@ -498,7 +502,7 @@ } if (is_string) { - if (!(gen->d.ia5 = ASN1_IA5STRING_new()) || + if ((gen->d.ia5 = ASN1_IA5STRING_new()) == NULL || !ASN1_STRING_set(gen->d.ia5, (unsigned char *)value, strlen(value))) { X509V3err(X509V3_F_A2I_GENERAL_NAME, ERR_R_MALLOC_FAILURE); @@ -560,16 +564,17 @@ { char *objtmp = NULL, *p; int objlen; - if (!(p = strchr(value, ';'))) + + if ((p = strchr(value, ';')) == NULL) return 0; - if (!(gen->d.otherName = OTHERNAME_new())) + if ((gen->d.otherName = OTHERNAME_new()) == NULL) return 0; /* * Free this up because we will overwrite it. no need to free type_id * because it is static */ ASN1_TYPE_free(gen->d.otherName->value); - if (!(gen->d.otherName->value = ASN1_generate_v3(p + 1, ctx))) + if ((gen->d.otherName->value = ASN1_generate_v3(p + 1, ctx)) == NULL) return 0; objlen = p - value; objtmp = OPENSSL_malloc(objlen + 1); @@ -588,8 +593,9 @@ { int ret = 0; STACK_OF(CONF_VALUE) *sk = NULL; - X509_NAME *nm = NULL; - if (!(nm = X509_NAME_new())) + X509_NAME *nm; + + if ((nm = X509_NAME_new()) == NULL) goto err; sk = X509V3_get_section(ctx, value); if (!sk) {
diff --git a/crypto/x509v3/v3_bcons.c b/crypto/x509v3/v3_bcons.c index 97bc079..3b89efb 100644 --- a/crypto/x509v3/v3_bcons.c +++ b/crypto/x509v3/v3_bcons.c
@@ -107,7 +107,8 @@ BASIC_CONSTRAINTS *bcons = NULL; CONF_VALUE *val; int i; - if (!(bcons = BASIC_CONSTRAINTS_new())) { + + if ((bcons = BASIC_CONSTRAINTS_new()) == NULL) { X509V3err(X509V3_F_V2I_BASIC_CONSTRAINTS, ERR_R_MALLOC_FAILURE); return NULL; }
diff --git a/crypto/x509v3/v3_bitst.c b/crypto/x509v3/v3_bitst.c index eb6d0f3..9072b42 100644 --- a/crypto/x509v3/v3_bitst.c +++ b/crypto/x509v3/v3_bitst.c
@@ -112,7 +112,7 @@ ASN1_BIT_STRING *bs; int i; BIT_STRING_BITNAME *bnam; - if (!(bs = ASN1_BIT_STRING_new())) { + if ((bs = ASN1_BIT_STRING_new()) == NULL) { X509V3err(X509V3_F_V2I_ASN1_BIT_STRING, ERR_R_MALLOC_FAILURE); return NULL; }
diff --git a/crypto/x509v3/v3_conf.c b/crypto/x509v3/v3_conf.c index 672d3de..51f39f5 100644 --- a/crypto/x509v3/v3_conf.c +++ b/crypto/x509v3/v3_conf.c
@@ -121,11 +121,12 @@ X509_EXTENSION *ext; STACK_OF(CONF_VALUE) *nval; void *ext_struc; + if (ext_nid == NID_undef) { X509V3err(X509V3_F_DO_EXT_NCONF, X509V3_R_UNKNOWN_EXTENSION_NAME); return NULL; } - if (!(method = X509V3_EXT_get_nid(ext_nid))) { + if ((method = X509V3_EXT_get_nid(ext_nid)) == NULL) { X509V3err(X509V3_F_DO_EXT_NCONF, X509V3_R_UNKNOWN_EXTENSION); return NULL; } @@ -148,14 +149,14 @@ if (!ext_struc) return NULL; } else if (method->s2i) { - if (!(ext_struc = method->s2i(method, ctx, value))) + if ((ext_struc = method->s2i(method, ctx, value)) == NULL) return NULL; } else if (method->r2i) { if (!ctx->db || !ctx->db_meth) { X509V3err(X509V3_F_DO_EXT_NCONF, X509V3_R_NO_CONFIG_DATABASE); return NULL; } - if (!(ext_struc = method->r2i(method, ctx, value))) + if ((ext_struc = method->r2i(method, ctx, value)) == NULL) return NULL; } else { X509V3err(X509V3_F_DO_EXT_NCONF, @@ -189,13 +190,14 @@ goto merr; } else { unsigned char *p; + ext_len = method->i2d(ext_struc, NULL); - if (!(ext_der = OPENSSL_malloc(ext_len))) + if ((ext_der = OPENSSL_malloc(ext_len)) == NULL) goto merr; p = ext_der; method->i2d(ext_struc, &p); } - if (!(ext_oct = ASN1_OCTET_STRING_new())) + if ((ext_oct = ASN1_OCTET_STRING_new()) == NULL) goto merr; ext_oct->data = ext_der; ext_der = NULL; @@ -221,7 +223,8 @@ X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc) { const X509V3_EXT_METHOD *method; - if (!(method = X509V3_EXT_get_nid(ext_nid))) { + + if ((method = X509V3_EXT_get_nid(ext_nid)) == NULL) { X509V3err(X509V3_F_X509V3_EXT_I2D, X509V3_R_UNKNOWN_EXTENSION); return NULL; } @@ -271,7 +274,8 @@ ASN1_OBJECT *obj = NULL; ASN1_OCTET_STRING *oct = NULL; X509_EXTENSION *extension = NULL; - if (!(obj = OBJ_txt2obj(ext, 0))) { + + if ((obj = OBJ_txt2obj(ext, 0)) == NULL) { X509V3err(X509V3_F_V3_GENERIC_EXTENSION, X509V3_R_EXTENSION_NAME_ERROR); ERR_add_error_data(2, "name=", ext); @@ -290,7 +294,7 @@ goto err; } - if (!(oct = ASN1_OCTET_STRING_new())) { + if ((oct = ASN1_OCTET_STRING_new()) == NULL) { X509V3err(X509V3_F_V3_GENERIC_EXTENSION, ERR_R_MALLOC_FAILURE); goto err; } @@ -346,11 +350,12 @@ STACK_OF(CONF_VALUE) *nval; CONF_VALUE *val; int i; - if (!(nval = NCONF_get_section(conf, section))) + + if ((nval = NCONF_get_section(conf, section)) == NULL) return 0; for (i = 0; i < sk_CONF_VALUE_num(nval); i++) { val = sk_CONF_VALUE_value(nval, i); - if (!(ext = X509V3_EXT_nconf(conf, ctx, val->name, val->value))) + if ((ext = X509V3_EXT_nconf(conf, ctx, val->name, val->value)) == NULL) return 0; if (ctx->flags == X509V3_CTX_REPLACE) delete_ext(*sk, ext);
diff --git a/crypto/x509v3/v3_cpols.c b/crypto/x509v3/v3_cpols.c index b7f8079..cac91b9 100644 --- a/crypto/x509v3/v3_cpols.c +++ b/crypto/x509v3/v3_cpols.c
@@ -176,10 +176,10 @@ } pol = policy_section(ctx, polsect, ia5org); X509V3_section_free(ctx, polsect); - if (!pol) + if (pol == NULL) goto err; } else { - if (!(pobj = OBJ_txt2obj(cnf->name, 0))) { + if ((pobj = OBJ_txt2obj(cnf->name, 0)) == NULL) { X509V3err(X509V3_F_R2I_CERTPOL, X509V3_R_INVALID_OBJECT_IDENTIFIER); X509V3_conf_err(cnf); @@ -209,13 +209,14 @@ CONF_VALUE *cnf; POLICYINFO *pol; POLICYQUALINFO *qual; - if (!(pol = POLICYINFO_new())) + + if ((pol = POLICYINFO_new()) == NULL) goto merr; for (i = 0; i < sk_CONF_VALUE_num(polstrs); i++) { cnf = sk_CONF_VALUE_value(polstrs, i); if (strcmp(cnf->name, "policyIdentifier") == 0) { ASN1_OBJECT *pobj; - if (!(pobj = OBJ_txt2obj(cnf->value, 0))) { + if ((pobj = OBJ_txt2obj(cnf->value, 0)) == NULL) { X509V3err(X509V3_F_POLICY_SECTION, X509V3_R_INVALID_OBJECT_IDENTIFIER); X509V3_conf_err(cnf); @@ -224,17 +225,17 @@ pol->policyid = pobj; } else if (!name_cmp(cnf->name, "CPS")) { - if (!pol->qualifiers) + if (pol->qualifiers == NULL) pol->qualifiers = sk_POLICYQUALINFO_new_null(); - if (!(qual = POLICYQUALINFO_new())) + if ((qual = POLICYQUALINFO_new()) == NULL) goto merr; if (!sk_POLICYQUALINFO_push(pol->qualifiers, qual)) goto merr; - if (!(qual->pqualid = OBJ_nid2obj(NID_id_qt_cps))) { + if ((qual->pqualid = OBJ_nid2obj(NID_id_qt_cps)) == NULL) { X509V3err(X509V3_F_POLICY_SECTION, ERR_R_INTERNAL_ERROR); goto err; } - if (!(qual->d.cpsuri = ASN1_IA5STRING_new())) + if ((qual->d.cpsuri = ASN1_IA5STRING_new()) == NULL) goto merr; if (!ASN1_STRING_set(qual->d.cpsuri, cnf->value, strlen(cnf->value))) @@ -292,19 +293,20 @@ CONF_VALUE *cnf; USERNOTICE *not; POLICYQUALINFO *qual; - if (!(qual = POLICYQUALINFO_new())) + + if ((qual = POLICYQUALINFO_new()) == NULL) goto merr; - if (!(qual->pqualid = OBJ_nid2obj(NID_id_qt_unotice))) { + if ((qual->pqualid = OBJ_nid2obj(NID_id_qt_unotice)) == NULL) { X509V3err(X509V3_F_NOTICE_SECTION, ERR_R_INTERNAL_ERROR); goto err; } - if (!(not = USERNOTICE_new())) + if ((not = USERNOTICE_new()) == NULL) goto merr; qual->d.usernotice = not; for (i = 0; i < sk_CONF_VALUE_num(unot); i++) { cnf = sk_CONF_VALUE_value(unot, i); if (strcmp(cnf->name, "explicitText") == 0) { - if (!(not->exptext = ASN1_VISIBLESTRING_new())) + if ((not->exptext = ASN1_VISIBLESTRING_new()) == NULL) goto merr; if (!ASN1_STRING_set(not->exptext, cnf->value, strlen(cnf->value))) @@ -312,7 +314,7 @@ } else if (strcmp(cnf->name, "organization") == 0) { NOTICEREF *nref; if (!not->noticeref) { - if (!(nref = NOTICEREF_new())) + if ((nref = NOTICEREF_new()) == NULL) goto merr; not->noticeref = nref; } else @@ -328,7 +330,7 @@ NOTICEREF *nref; STACK_OF(CONF_VALUE) *nos; if (!not->noticeref) { - if (!(nref = NOTICEREF_new())) + if ((nref = NOTICEREF_new()) == NULL) goto merr; not->noticeref = nref; } else @@ -376,7 +378,7 @@ for (i = 0; i < sk_CONF_VALUE_num(nos); i++) { cnf = sk_CONF_VALUE_value(nos, i); - if (!(aint = s2i_ASN1_INTEGER(NULL, cnf->name))) { + if ((aint = s2i_ASN1_INTEGER(NULL, cnf->name)) == NULL) { X509V3err(X509V3_F_NREF_NOS, X509V3_R_INVALID_NUMBER); goto err; }
diff --git a/crypto/x509v3/v3_crld.c b/crypto/x509v3/v3_crld.c index b72ae43..67d019a 100644 --- a/crypto/x509v3/v3_crld.c +++ b/crypto/x509v3/v3_crld.c
@@ -291,7 +291,8 @@ GENERAL_NAME *gen = NULL; CONF_VALUE *cnf; int i; - if (!(crld = sk_DIST_POINT_new_null())) + + if ((crld = sk_DIST_POINT_new_null()) == NULL) goto merr; for (i = 0; i < sk_CONF_VALUE_num(nval); i++) { DIST_POINT *point; @@ -310,20 +311,20 @@ goto merr; } } else { - if (!(gen = v2i_GENERAL_NAME(method, ctx, cnf))) + if ((gen = v2i_GENERAL_NAME(method, ctx, cnf)) == NULL) goto err; - if (!(gens = GENERAL_NAMES_new())) + if ((gens = GENERAL_NAMES_new()) == NULL) goto merr; if (!sk_GENERAL_NAME_push(gens, gen)) goto merr; gen = NULL; - if (!(point = DIST_POINT_new())) + if ((point = DIST_POINT_new()) == NULL) goto merr; if (!sk_DIST_POINT_push(crld, point)) { DIST_POINT_free(point); goto merr; } - if (!(point->distpoint = DIST_POINT_NAME_new())) + if ((point->distpoint = DIST_POINT_NAME_new()) == NULL) goto merr; point->distpoint->name.fullname = gens; point->distpoint->type = 0;
diff --git a/crypto/x509v3/v3_extku.c b/crypto/x509v3/v3_extku.c index 6092c2e..70d3554 100644 --- a/crypto/x509v3/v3_extku.c +++ b/crypto/x509v3/v3_extku.c
@@ -125,7 +125,7 @@ CONF_VALUE *val; int i; - if (!(extku = sk_ASN1_OBJECT_new_null())) { + if ((extku = sk_ASN1_OBJECT_new_null()) == NULL) { X509V3err(X509V3_F_V2I_EXTENDED_KEY_USAGE, ERR_R_MALLOC_FAILURE); return NULL; } @@ -136,7 +136,7 @@ extval = val->value; else extval = val->name; - if (!(objtmp = OBJ_txt2obj(extval, 0))) { + if ((objtmp = OBJ_txt2obj(extval, 0)) == NULL) { sk_ASN1_OBJECT_pop_free(extku, ASN1_OBJECT_free); X509V3err(X509V3_F_V2I_EXTENDED_KEY_USAGE, X509V3_R_INVALID_OBJECT_IDENTIFIER);
diff --git a/crypto/x509v3/v3_ia5.c b/crypto/x509v3/v3_ia5.c index 42a0d86..7cae1b6 100644 --- a/crypto/x509v3/v3_ia5.c +++ b/crypto/x509v3/v3_ia5.c
@@ -77,9 +77,10 @@ char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5) { char *tmp; + if (!ia5 || !ia5->length) return NULL; - if (!(tmp = OPENSSL_malloc(ia5->length + 1))) { + if ((tmp = OPENSSL_malloc(ia5->length + 1)) == NULL) { X509V3err(X509V3_F_I2S_ASN1_IA5STRING, ERR_R_MALLOC_FAILURE); return NULL; } @@ -97,7 +98,7 @@ X509V3_R_INVALID_NULL_ARGUMENT); return NULL; } - if (!(ia5 = ASN1_IA5STRING_new())) + if ((ia5 = ASN1_IA5STRING_new()) == NULL) goto err; if (!ASN1_STRING_set((ASN1_STRING *)ia5, (unsigned char *)str, strlen(str))) {
diff --git a/crypto/x509v3/v3_info.c b/crypto/x509v3/v3_info.c index a377c92..872d5c7 100644 --- a/crypto/x509v3/v3_info.c +++ b/crypto/x509v3/v3_info.c
@@ -153,13 +153,14 @@ ACCESS_DESCRIPTION *acc; int i, objlen; char *objtmp, *ptmp; - if (!(ainfo = sk_ACCESS_DESCRIPTION_new_null())) { + + if ((ainfo = sk_ACCESS_DESCRIPTION_new_null()) == NULL) { X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS, ERR_R_MALLOC_FAILURE); return NULL; } for (i = 0; i < sk_CONF_VALUE_num(nval); i++) { cnf = sk_CONF_VALUE_value(nval, i); - if (!(acc = ACCESS_DESCRIPTION_new()) + if ((acc = ACCESS_DESCRIPTION_new()) == NULL || !sk_ACCESS_DESCRIPTION_push(ainfo, acc)) { X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS, ERR_R_MALLOC_FAILURE); @@ -176,7 +177,7 @@ ctmp.value = cnf->value; if (!v2i_GENERAL_NAME_ex(acc->location, method, ctx, &ctmp, 0)) goto err; - if (!(objtmp = OPENSSL_malloc(objlen + 1))) { + if ((objtmp = OPENSSL_malloc(objlen + 1)) == NULL) { X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS, ERR_R_MALLOC_FAILURE); goto err;
diff --git a/crypto/x509v3/v3_lib.c b/crypto/x509v3/v3_lib.c index c091b04..4bec817 100644 --- a/crypto/x509v3/v3_lib.c +++ b/crypto/x509v3/v3_lib.c
@@ -73,7 +73,8 @@ int X509V3_EXT_add(X509V3_EXT_METHOD *ext) { - if (!ext_list && !(ext_list = sk_X509V3_EXT_METHOD_new(ext_cmp))) { + if (ext_list == NULL + && (ext_list = sk_X509V3_EXT_METHOD_new(ext_cmp)) == NULL) { X509V3err(X509V3_F_X509V3_EXT_ADD, ERR_R_MALLOC_FAILURE); return 0; } @@ -135,12 +136,11 @@ const X509V3_EXT_METHOD *ext; X509V3_EXT_METHOD *tmpext; - if (!(ext = X509V3_EXT_get_nid(nid_from))) { - X509V3err(X509V3_F_X509V3_EXT_ADD_ALIAS, - X509V3_R_EXTENSION_NOT_FOUND); + if ((ext = X509V3_EXT_get_nid(nid_from)) == NULL) { + X509V3err(X509V3_F_X509V3_EXT_ADD_ALIAS, X509V3_R_EXTENSION_NOT_FOUND); return 0; } - if (!(tmpext = OPENSSL_malloc(sizeof(*tmpext)))) { + if ((tmpext = OPENSSL_malloc(sizeof(*tmpext))) == NULL) { X509V3err(X509V3_F_X509V3_EXT_ADD_ALIAS, ERR_R_MALLOC_FAILURE); return 0; } @@ -181,7 +181,7 @@ ASN1_STRING *extvalue; int extlen; - if (!(method = X509V3_EXT_get(ext))) + if ((method = X509V3_EXT_get(ext)) == NULL) return NULL; extvalue = X509_EXTENSION_get_data(ext); p = ASN1_STRING_data(extvalue); @@ -326,7 +326,8 @@ return 1; } - if (!*x && !(*x = sk_X509_EXTENSION_new_null())) + if (*x == NULL + && (*x = sk_X509_EXTENSION_new_null()) == NULL) return -1; if (!sk_X509_EXTENSION_push(*x, ext)) return -1;
diff --git a/crypto/x509v3/v3_pci.c b/crypto/x509v3/v3_pci.c index 2568ea8..c795db7 100644 --- a/crypto/x509v3/v3_pci.c +++ b/crypto/x509v3/v3_pci.c
@@ -86,7 +86,7 @@ X509V3_conf_err(val); return 0; } - if (!(*language = OBJ_txt2obj(val->value, 0))) { + if ((*language = OBJ_txt2obj(val->value, 0)) == NULL) { X509V3err(X509V3_F_PROCESS_PCI_VALUE, X509V3_R_INVALID_OBJECT_IDENTIFIER); X509V3_conf_err(val);
diff --git a/crypto/x509v3/v3_pcons.c b/crypto/x509v3/v3_pcons.c index 3349cef..a1b27d6 100644 --- a/crypto/x509v3/v3_pcons.c +++ b/crypto/x509v3/v3_pcons.c
@@ -108,7 +108,8 @@ POLICY_CONSTRAINTS *pcons = NULL; CONF_VALUE *val; int i; - if (!(pcons = POLICY_CONSTRAINTS_new())) { + + if ((pcons = POLICY_CONSTRAINTS_new()) == NULL) { X509V3err(X509V3_F_V2I_POLICY_CONSTRAINTS, ERR_R_MALLOC_FAILURE); return NULL; }
diff --git a/crypto/x509v3/v3_pmaps.c b/crypto/x509v3/v3_pmaps.c index a168343..14253aa 100644 --- a/crypto/x509v3/v3_pmaps.c +++ b/crypto/x509v3/v3_pmaps.c
@@ -119,7 +119,7 @@ CONF_VALUE *val; int i; - if (!(pmaps = sk_POLICY_MAPPING_new_null())) { + if ((pmaps = sk_POLICY_MAPPING_new_null()) == NULL) { X509V3err(X509V3_F_V2I_POLICY_MAPPINGS, ERR_R_MALLOC_FAILURE); return NULL; }
diff --git a/crypto/x509v3/v3_prn.c b/crypto/x509v3/v3_prn.c index 633daca..2d51674 100644 --- a/crypto/x509v3/v3_prn.c +++ b/crypto/x509v3/v3_prn.c
@@ -131,7 +131,7 @@ p = ASN1_STRING_data(extoct); extlen = ASN1_STRING_length(extoct); - if (!(method = X509V3_EXT_get(ext))) + if ((method = X509V3_EXT_get(ext)) == NULL) return unknown_ext_print(out, p, extlen, flag, indent, 0); if (method->it) ext_str = ASN1_item_d2i(NULL, &p, extlen, ASN1_ITEM_ptr(method->it)); @@ -142,7 +142,7 @@ return unknown_ext_print(out, p, extlen, flag, indent, 1); if (method->i2s) { - if (!(value = method->i2s(method, ext_str))) { + if ((value = method->i2s(method, ext_str)) == NULL) { ok = 0; goto err; } @@ -162,7 +162,7 @@ } #endif } else if (method->i2v) { - if (!(nval = method->i2v(method, ext_str, NULL))) { + if ((nval = method->i2v(method, ext_str, NULL)) == NULL) { ok = 0; goto err; } @@ -249,7 +249,8 @@ { BIO *bio_tmp; int ret; - if (!(bio_tmp = BIO_new_fp(fp, BIO_NOCLOSE))) + + if ((bio_tmp = BIO_new_fp(fp, BIO_NOCLOSE)) == NULL) return 0; ret = X509V3_EXT_print(bio_tmp, ext, flag, indent); BIO_free(bio_tmp);
diff --git a/crypto/x509v3/v3_purp.c b/crypto/x509v3/v3_purp.c index beb8b2f..dc72795 100644 --- a/crypto/x509v3/v3_purp.c +++ b/crypto/x509v3/v3_purp.c
@@ -209,7 +209,7 @@ idx = X509_PURPOSE_get_by_id(id); /* Need a new entry */ if (idx == -1) { - if (!(ptmp = OPENSSL_malloc(sizeof(*ptmp)))) { + if ((ptmp = OPENSSL_malloc(sizeof(*ptmp))) == NULL) { X509V3err(X509V3_F_X509_PURPOSE_ADD, ERR_R_MALLOC_FAILURE); return 0; } @@ -241,7 +241,8 @@ /* If its a new entry manage the dynamic table */ if (idx == -1) { - if (!xptable && !(xptable = sk_X509_PURPOSE_new(xp_cmp))) { + if (xptable == NULL + && (xptable = sk_X509_PURPOSE_new(xp_cmp)) == NULL) { X509V3err(X509V3_F_X509_PURPOSE_ADD, ERR_R_MALLOC_FAILURE); return 0; }
diff --git a/crypto/x509v3/v3_skey.c b/crypto/x509v3/v3_skey.c index 705d86c..977844b 100644 --- a/crypto/x509v3/v3_skey.c +++ b/crypto/x509v3/v3_skey.c
@@ -83,12 +83,12 @@ ASN1_OCTET_STRING *oct; long length; - if (!(oct = ASN1_OCTET_STRING_new())) { + if ((oct = ASN1_OCTET_STRING_new()) == NULL) { X509V3err(X509V3_F_S2I_ASN1_OCTET_STRING, ERR_R_MALLOC_FAILURE); return NULL; } - if (!(oct->data = string_to_hex(str, &length))) { + if ((oct->data = string_to_hex(str, &length)) == NULL) { ASN1_OCTET_STRING_free(oct); return NULL; } @@ -110,7 +110,7 @@ if (strcmp(str, "hash")) return s2i_ASN1_OCTET_STRING(method, ctx, str); - if (!(oct = ASN1_OCTET_STRING_new())) { + if ((oct = ASN1_OCTET_STRING_new()) == NULL) { X509V3err(X509V3_F_S2I_SKEY_ID, ERR_R_MALLOC_FAILURE); return NULL; }
diff --git a/crypto/x509v3/v3_sxnet.c b/crypto/x509v3/v3_sxnet.c index ecd1ec6..fff3b00 100644 --- a/crypto/x509v3/v3_sxnet.c +++ b/crypto/x509v3/v3_sxnet.c
@@ -152,8 +152,9 @@ int SXNET_add_id_asc(SXNET **psx, char *zone, char *user, int userlen) { - ASN1_INTEGER *izone = NULL; - if (!(izone = s2i_ASN1_INTEGER(NULL, zone))) { + ASN1_INTEGER *izone; + + if ((izone = s2i_ASN1_INTEGER(NULL, zone)) == NULL) { X509V3err(X509V3_F_SXNET_ADD_ID_ASC, X509V3_R_ERROR_CONVERTING_ZONE); return 0; } @@ -165,8 +166,10 @@ int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, char *user, int userlen) { - ASN1_INTEGER *izone = NULL; - if (!(izone = ASN1_INTEGER_new()) || !ASN1_INTEGER_set(izone, lzone)) { + ASN1_INTEGER *izone; + + if ((izone = ASN1_INTEGER_new()) == NULL + || !ASN1_INTEGER_set(izone, lzone)) { X509V3err(X509V3_F_SXNET_ADD_ID_ULONG, ERR_R_MALLOC_FAILURE); ASN1_INTEGER_free(izone); return 0; @@ -196,8 +199,8 @@ X509V3err(X509V3_F_SXNET_ADD_ID_INTEGER, X509V3_R_USER_TOO_LONG); return 0; } - if (!*psx) { - if (!(sx = SXNET_new())) + if (*psx == NULL) { + if ((sx = SXNET_new()) == NULL) goto err; if (!ASN1_INTEGER_set(sx->version, 0)) goto err; @@ -209,7 +212,7 @@ return 0; } - if (!(id = SXNETID_new())) + if ((id = SXNETID_new()) == NULL) goto err; if (userlen == -1) userlen = strlen(user); @@ -231,9 +234,10 @@ ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, char *zone) { - ASN1_INTEGER *izone = NULL; + ASN1_INTEGER *izone; ASN1_OCTET_STRING *oct; - if (!(izone = s2i_ASN1_INTEGER(NULL, zone))) { + + if ((izone = s2i_ASN1_INTEGER(NULL, zone)) == NULL) { X509V3err(X509V3_F_SXNET_GET_ID_ASC, X509V3_R_ERROR_CONVERTING_ZONE); return NULL; } @@ -244,9 +248,11 @@ ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone) { - ASN1_INTEGER *izone = NULL; + ASN1_INTEGER *izone; ASN1_OCTET_STRING *oct; - if (!(izone = ASN1_INTEGER_new()) || !ASN1_INTEGER_set(izone, lzone)) { + + if ((izone = ASN1_INTEGER_new()) == NULL + || !ASN1_INTEGER_set(izone, lzone)) { X509V3err(X509V3_F_SXNET_GET_ID_ULONG, ERR_R_MALLOC_FAILURE); ASN1_INTEGER_free(izone); return NULL;
diff --git a/crypto/x509v3/v3_utl.c b/crypto/x509v3/v3_utl.c index c6aab4b..d50c2fa 100644 --- a/crypto/x509v3/v3_utl.c +++ b/crypto/x509v3/v3_utl.c
@@ -84,13 +84,14 @@ { CONF_VALUE *vtmp = NULL; char *tname = NULL, *tvalue = NULL; - if (name && !(tname = BUF_strdup(name))) + + if (name && (tname = BUF_strdup(name)) == NULL) goto err; - if (value && !(tvalue = BUF_strdup(value))) + if (value && (tvalue = BUF_strdup(value)) == NULL) goto err; - if (!(vtmp = OPENSSL_malloc(sizeof(*vtmp)))) + if ((vtmp = OPENSSL_malloc(sizeof(*vtmp))) == NULL) goto err; - if (!*extlist && !(*extlist = sk_CONF_VALUE_new_null())) + if (*extlist == NULL && (*extlist = sk_CONF_VALUE_new_null()) == NULL) goto err; vtmp->section = NULL; vtmp->name = tname; @@ -144,10 +145,11 @@ { BIGNUM *bntmp = NULL; char *strtmp = NULL; + if (!a) return NULL; - if (!(bntmp = ASN1_ENUMERATED_to_BN(a, NULL)) || - !(strtmp = BN_bn2dec(bntmp))) + if ((bntmp = ASN1_ENUMERATED_to_BN(a, NULL)) == NULL + || (strtmp = BN_bn2dec(bntmp)) == NULL) X509V3err(X509V3_F_I2S_ASN1_ENUMERATED, ERR_R_MALLOC_FAILURE); BN_free(bntmp); return strtmp; @@ -157,10 +159,11 @@ { BIGNUM *bntmp = NULL; char *strtmp = NULL; + if (!a) return NULL; - if (!(bntmp = ASN1_INTEGER_to_BN(a, NULL)) || - !(strtmp = BN_bn2dec(bntmp))) + if ((bntmp = ASN1_INTEGER_to_BN(a, NULL)) == NULL + || (strtmp = BN_bn2dec(bntmp)) == NULL) X509V3err(X509V3_F_I2S_ASN1_INTEGER, ERR_R_MALLOC_FAILURE); BN_free(bntmp); return strtmp; @@ -220,9 +223,10 @@ { char *strtmp; int ret; + if (!aint) return 1; - if (!(strtmp = i2s_ASN1_INTEGER(NULL, aint))) + if ((strtmp = i2s_ASN1_INTEGER(NULL, aint)) == NULL) return 0; ret = X509V3_add_value(name, strtmp, extlist); OPENSSL_free(strtmp); @@ -232,7 +236,8 @@ int X509V3_get_value_bool(CONF_VALUE *value, int *asn1_bool) { char *btmp; - if (!(btmp = value->value)) + + if ((btmp = value->value) == NULL) goto err; if (strcmp(btmp, "TRUE") == 0 || strcmp(btmp, "true") == 0 @@ -262,7 +267,8 @@ int X509V3_get_value_int(CONF_VALUE *value, ASN1_INTEGER **aint) { ASN1_INTEGER *itmp; - if (!(itmp = s2i_ASN1_INTEGER(NULL, value->value))) { + + if ((itmp = s2i_ASN1_INTEGER(NULL, value->value)) == NULL) { X509V3_conf_err(value); return 0; } @@ -401,7 +407,7 @@ const static char hexdig[] = "0123456789ABCDEF"; if (!buffer || !len) return NULL; - if (!(tmp = OPENSSL_malloc(len * 3 + 1))) { + if ((tmp = OPENSSL_malloc(len * 3 + 1)) == NULL) { X509V3err(X509V3_F_HEX_TO_STRING, ERR_R_MALLOC_FAILURE); return NULL; } @@ -431,7 +437,7 @@ X509V3err(X509V3_F_STRING_TO_HEX, X509V3_R_INVALID_NULL_ARGUMENT); return NULL; } - if (!(hexbuf = OPENSSL_malloc(strlen(str) >> 1))) + if ((hexbuf = OPENSSL_malloc(strlen(str) >> 1)) == NULL) goto err; for (p = (unsigned char *)str, q = hexbuf; *p;) { ch = *p++;
diff --git a/crypto/x509v3/v3prin.c b/crypto/x509v3/v3prin.c index cbc3570..36ca040 100644 --- a/crypto/x509v3/v3prin.c +++ b/crypto/x509v3/v3prin.c
@@ -69,17 +69,18 @@ FILE *inf; int i, count; X509_EXTENSION *ext; + X509V3_add_standard_extensions(); ERR_load_crypto_strings(); if (!argv[1]) { fprintf(stderr, "Usage v3prin cert.pem\n"); exit(1); } - if (!(inf = fopen(argv[1], "r"))) { + if ((inf = fopen(argv[1], "r")) == NULL) { fprintf(stderr, "Can't open %s\n", argv[1]); exit(1); } - if (!(cert = PEM_read_X509(inf, NULL, NULL))) { + if ((cert = PEM_read_X509(inf, NULL, NULL)) == NULL) { fprintf(stderr, "Can't read certificate %s\n", argv[1]); ERR_print_errors_fp(stderr); exit(1);