Browse Source

Use p==NULL not !p (in if statements, mainly)

Reviewed-by: Tim Hudson <tjh@openssl.org>
master
Rich Salz 7 years ago
committed by Rich Salz
parent
commit
75ebbd9aa4
118 changed files with 754 additions and 724 deletions
  1. +3
    -2
      apps/apps.c
  2. +1
    -1
      apps/ca.c
  3. +11
    -11
      apps/cms.c
  4. +1
    -1
      apps/crl.c
  5. +2
    -1
      apps/crl2p7.c
  6. +9
    -9
      apps/pkcs12.c
  7. +5
    -5
      apps/pkcs8.c
  8. +1
    -1
      apps/req.c
  9. +2
    -1
      apps/s_client.c
  10. +6
    -6
      apps/smime.c
  11. +16
    -11
      apps/srp.c
  12. +42
    -40
      apps/ts.c
  13. +1
    -1
      apps/verify.c
  14. +1
    -3
      apps/x509.c
  15. +1
    -1
      crypto/asn1/a_mbstr.c
  16. +2
    -2
      crypto/asn1/a_time.c
  17. +9
    -20
      crypto/asn1/asn1_gen.c
  18. +17
    -12
      crypto/asn1/asn_mime.c
  19. +2
    -1
      crypto/asn1/asn_moid.c
  20. +2
    -1
      crypto/asn1/asn_mstbl.c
  21. +4
    -4
      crypto/asn1/asn_pack.c
  22. +8
    -9
      crypto/asn1/p5_pbev2.c
  23. +14
    -11
      crypto/asn1/x_x509a.c
  24. +1
    -1
      crypto/bio/bf_nbio.c
  25. +1
    -1
      crypto/bio/bss_conn.c
  26. +1
    -1
      crypto/bio/bss_dgram.c
  27. +2
    -2
      crypto/bio/bss_mem.c
  28. +2
    -1
      crypto/cms/cms_smime.c
  29. +1
    -1
      crypto/conf/conf_def.c
  30. +4
    -4
      crypto/conf/conf_lib.c
  31. +11
    -10
      crypto/dh/dh_ameth.c
  32. +15
    -13
      crypto/dsa/dsa_ameth.c
  33. +5
    -3
      crypto/ec/ec_ameth.c
  34. +1
    -1
      crypto/ec/ec_asn1.c
  35. +6
    -6
      crypto/ec/ec_curve.c
  36. +3
    -2
      crypto/ec/ec_mult.c
  37. +1
    -1
      crypto/ec/ec_pmeth.c
  38. +2
    -1
      crypto/evp/evp_cnf.c
  39. +3
    -2
      crypto/evp/evp_pbe.c
  40. +2
    -2
      crypto/evp/evp_pkey.c
  41. +1
    -1
      crypto/evp/pmeth_lib.c
  42. +5
    -5
      crypto/objects/obj_dat.c
  43. +4
    -3
      crypto/ocsp/ocsp_cl.c
  44. +14
    -13
      crypto/ocsp/ocsp_ext.c
  45. +3
    -3
      crypto/ocsp/ocsp_lib.c
  46. +1
    -1
      crypto/ocsp/ocsp_prn.c
  47. +12
    -10
      crypto/ocsp/ocsp_srv.c
  48. +2
    -1
      crypto/ocsp/ocsp_vfy.c
  49. +6
    -3
      crypto/pem/pem_pk8.c
  50. +2
    -3
      crypto/pem/pvkfmt.c
  51. +11
    -7
      crypto/pkcs12/p12_add.c
  52. +2
    -1
      crypto/pkcs12/p12_attr.c
  53. +2
    -2
      crypto/pkcs12/p12_crt.c
  54. +4
    -2
      crypto/pkcs12/p12_decr.c
  55. +3
    -2
      crypto/pkcs12/p12_init.c
  56. +4
    -4
      crypto/pkcs12/p12_kiss.c
  57. +6
    -5
      crypto/pkcs12/p12_mutl.c
  58. +7
    -7
      crypto/pkcs12/p12_npas.c
  59. +2
    -2
      crypto/pkcs12/p12_p8e.c
  60. +4
    -2
      crypto/pkcs12/p12_utl.c
  61. +7
    -6
      crypto/pkcs7/pk7_attr.c
  62. +3
    -4
      crypto/pkcs7/pk7_doit.c
  63. +3
    -3
      crypto/pkcs7/pk7_lib.c
  64. +11
    -11
      crypto/pkcs7/pk7_smime.c
  65. +4
    -2
      crypto/rsa/rsa_ameth.c
  66. +2
    -2
      crypto/rsa/rsa_pmeth.c
  67. +6
    -7
      crypto/srp/srp_lib.c
  68. +10
    -9
      crypto/srp/srp_vfy.c
  69. +34
    -27
      crypto/ts/ts_conf.c
  70. +58
    -49
      crypto/ts/ts_rsp_sign.c
  71. +10
    -9
      crypto/ts/ts_rsp_verify.c
  72. +5
    -5
      crypto/ts/ts_verify_ctx.c
  73. +1
    -1
      crypto/txt_db/txt_db.c
  74. +2
    -2
      crypto/x509/x509_att.c
  75. +4
    -3
      crypto/x509/x509_trs.c
  76. +1
    -1
      crypto/x509/x509spki.c
  77. +1
    -1
      crypto/x509v3/pcy_tree.c
  78. +3
    -3
      crypto/x509v3/v3_akey.c
  79. +22
    -16
      crypto/x509v3/v3_alt.c
  80. +2
    -1
      crypto/x509v3/v3_bcons.c
  81. +1
    -1
      crypto/x509v3/v3_bitst.c
  82. +15
    -10
      crypto/x509v3/v3_conf.c
  83. +17
    -15
      crypto/x509v3/v3_cpols.c
  84. +6
    -5
      crypto/x509v3/v3_crld.c
  85. +2
    -2
      crypto/x509v3/v3_extku.c
  86. +3
    -2
      crypto/x509v3/v3_ia5.c
  87. +4
    -3
      crypto/x509v3/v3_info.c
  88. +8
    -7
      crypto/x509v3/v3_lib.c
  89. +1
    -1
      crypto/x509v3/v3_pci.c
  90. +2
    -1
      crypto/x509v3/v3_pcons.c
  91. +1
    -1
      crypto/x509v3/v3_pmaps.c
  92. +5
    -4
      crypto/x509v3/v3_prn.c
  93. +3
    -2
      crypto/x509v3/v3_purp.c
  94. +3
    -3
      crypto/x509v3/v3_skey.c
  95. +17
    -11
      crypto/x509v3/v3_sxnet.c
  96. +19
    -13
      crypto/x509v3/v3_utl.c
  97. +3
    -2
      crypto/x509v3/v3prin.c
  98. +12
    -17
      demos/engines/cluster_labs/hw_cluster_labs.c
  99. +5
    -5
      demos/engines/ibmca/hw_ibmca.c
  100. +26
    -44
      demos/engines/zencod/hw_zencod.c

+ 3
- 2
apps/apps.c View File

@ -502,11 +502,12 @@ int add_oid_section(CONF *conf)
STACK_OF(CONF_VALUE) *sktmp;
CONF_VALUE *cnf;
int i;
if (!(p = NCONF_get_string(conf, NULL, "oid_section"))) {
if ((p = NCONF_get_string(conf, NULL, "oid_section")) == NULL) {
ERR_clear_error();
return 1;
}
if (!(sktmp = NCONF_get_section(conf, p))) {
if ((sktmp = NCONF_get_section(conf, p)) == NULL) {
BIO_printf(bio_err, "problem loading oid section %s\n", p);
return 0;
}


+ 1
- 1
apps/ca.c View File

@ -1703,7 +1703,7 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
* Its best to dup the subject DN and then delete any email addresses
* because this retains its structure.
*/
if (!(dn_subject = X509_NAME_dup(subject))) {
if ((dn_subject = X509_NAME_dup(subject)) == NULL) {
BIO_printf(bio_err, "Memory allocation failure\n");
goto end;
}


+ 11
- 11
apps/cms.c View File

@ -717,8 +717,8 @@ int cms_main(int argc, char **argv)
if ((encerts = sk_X509_new_null()) == NULL)
goto end;
while (*argv) {
if (!(cert = load_cert(*argv, FORMAT_PEM,
NULL, e, "recipient certificate file")))
if ((cert = load_cert(*argv, FORMAT_PEM, NULL, e,
"recipient certificate file")) == NULL)
goto end;
sk_X509_push(encerts, cert);
cert = NULL;
@ -727,24 +727,24 @@ int cms_main(int argc, char **argv)
}
if (certfile) {
if (!(other = load_certs(certfile, FORMAT_PEM, NULL,
e, "certificate file"))) {
if ((other = load_certs(certfile, FORMAT_PEM, NULL, e,
"certificate file")) == NULL) {
ERR_print_errors(bio_err);
goto end;
}
}
if (recipfile && (operation == SMIME_DECRYPT)) {
if (!(recip = load_cert(recipfile, FORMAT_PEM, NULL,
e, "recipient certificate file"))) {
if ((recip = load_cert(recipfile, FORMAT_PEM, NULL, e,
"recipient certificate file")) == NULL) {
ERR_print_errors(bio_err);
goto end;
}
}
if (operation == SMIME_SIGN_RECEIPT) {
if (!(signer = load_cert(signerfile, FORMAT_PEM, NULL,
e, "receipt signer certificate file"))) {
if ((signer = load_cert(signerfile, FORMAT_PEM, NULL, e,
"receipt signer certificate file")) == NULL) {
ERR_print_errors(bio_err);
goto end;
}
@ -787,7 +787,7 @@ int cms_main(int argc, char **argv)
}
if (contfile) {
BIO_free(indata);
if (!(indata = BIO_new_file(contfile, "rb"))) {
if ((indata = BIO_new_file(contfile, "rb")) == NULL) {
BIO_printf(bio_err, "Can't read content file %s\n", contfile);
goto end;
}
@ -807,7 +807,7 @@ int cms_main(int argc, char **argv)
if (rctfile) {
char *rctmode = (rctformat == FORMAT_ASN1) ? "rb" : "r";
if (!(rctin = BIO_new_file(rctfile, rctmode))) {
if ((rctin = BIO_new_file(rctfile, rctmode)) == NULL) {
BIO_printf(bio_err, "Can't open receipt file %s\n", rctfile);
goto end;
}
@ -834,7 +834,7 @@ int cms_main(int argc, char **argv)
goto end;
if ((operation == SMIME_VERIFY) || (operation == SMIME_VERIFY_RECEIPT)) {
if (!(store = setup_verify(CAfile, CApath)))
if ((store = setup_verify(CAfile, CApath)) == NULL)
goto end;
X509_STORE_set_verify_cb(store, cms_cb);
if (vpmtouched)


+ 1
- 1
apps/crl.c View File

@ -222,7 +222,7 @@ int crl_main(int argc, char **argv)
goto end;
if (do_ver) {
if (!(store = setup_verify(CAfile, CApath)))
if ((store = setup_verify(CAfile, CApath)) == NULL)
goto end;
lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file());
if (lookup == NULL)


+ 2
- 1
apps/crl2p7.c View File

@ -135,7 +135,8 @@ int crl2pkcs7_main(int argc, char **argv)
nocrl = 1;
break;
case OPT_CERTFILE:
if (!certflst && !(certflst = sk_OPENSSL_STRING_new_null()))
if ((certflst == NULL)
&& (certflst = sk_OPENSSL_STRING_new_null()) == NULL)
goto end;
if (!sk_OPENSSL_STRING_push(certflst, *(++argv))) {
sk_OPENSSL_STRING_free(certflst);


+ 9
- 9
apps/pkcs12.c View File

@ -421,8 +421,8 @@ int pkcs12_main(int argc, char **argv)
/* Add any more certificates asked for */
if (certfile) {
STACK_OF(X509) *morecerts = NULL;
if (!(morecerts = load_certs(certfile, FORMAT_PEM, NULL, e,
"certificates from certfile")))
if ((morecerts = load_certs(certfile, FORMAT_PEM, NULL, e,
"certificates from certfile")) == NULL)
goto export_end;
while (sk_X509_num(morecerts) > 0)
sk_X509_push(certs, sk_X509_shift(morecerts));
@ -434,7 +434,7 @@ int pkcs12_main(int argc, char **argv)
int vret;
STACK_OF(X509) *chain2;
X509_STORE *store;
if (!(store = setup_verify(CAfile, CApath)))
if ((store = setup_verify(CAfile, CApath)) == NULL)
goto export_end;
vret = get_cert_chain(ucert, store, &chain2);
@ -511,7 +511,7 @@ int pkcs12_main(int argc, char **argv)
}
if (!(p12 = d2i_PKCS12_bio(in, NULL))) {
if ((p12 = d2i_PKCS12_bio(in, NULL)) == NULL) {
ERR_print_errors(bio_err);
goto end;
}
@ -570,7 +570,7 @@ int dump_certs_keys_p12(BIO *out, PKCS12 *p12, char *pass,
int ret = 0;
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);
@ -634,7 +634,7 @@ int dump_certs_pkeys_bag(BIO *out, PKCS12_SAFEBAG *bag, char *pass,
return 1;
print_attribs(out, bag->attrib, "Bag Attributes");
p8 = bag->value.keybag;
if (!(pkey = EVP_PKCS82PKEY(p8)))
if ((pkey = EVP_PKCS82PKEY(p8)) == NULL)
return 0;
print_attribs(out, p8->attributes, "Key Attributes");
PEM_write_bio_PrivateKey(out, pkey, enc, NULL, 0, NULL, pempass);
@ -649,9 +649,9 @@ int dump_certs_pkeys_bag(BIO *out, PKCS12_SAFEBAG *bag, char *pass,
if (options & NOKEYS)
return 1;
print_attribs(out, bag->attrib, "Bag Attributes");
if (!(p8 = PKCS12_decrypt_skey(bag, pass, passlen)))
if ((p8 = PKCS12_decrypt_skey(bag, pass, passlen)) == NULL)
return 0;
if (!(pkey = EVP_PKCS82PKEY(p8))) {
if ((pkey = EVP_PKCS82PKEY(p8)) == NULL) {
PKCS8_PRIV_KEY_INFO_free(p8);
return 0;
}
@ -674,7 +674,7 @@ int dump_certs_pkeys_bag(BIO *out, PKCS12_SAFEBAG *bag, char *pass,
print_attribs(out, bag->attrib, "Bag Attributes");
if (M_PKCS12_cert_bag_type(bag) != NID_x509Certificate)
return 1;
if (!(x509 = PKCS12_certbag2x509(bag)))
if ((x509 = PKCS12_certbag2x509(bag)) == NULL)
return 0;
dump_cert_text(out, x509);
PEM_write_bio_X509(out, x509);


+ 5
- 5
apps/pkcs8.c View File

@ -211,7 +211,7 @@ int pkcs8_main(int argc, char **argv)
pkey = load_key(infile, informat, 1, passin, e, "key");
if (!pkey)
goto end;
if (!(p8inf = EVP_PKEY2PKCS8_broken(pkey, p8_broken))) {
if ((p8inf = EVP_PKEY2PKCS8_broken(pkey, p8_broken)) == NULL) {
BIO_printf(bio_err, "Error converting key\n");
ERR_print_errors(bio_err);
goto end;
@ -235,9 +235,9 @@ int pkcs8_main(int argc, char **argv)
goto end;
}
app_RAND_load_file(NULL, 0);
if (!(p8 = PKCS8_encrypt(pbe_nid, cipher,
p8pass, strlen(p8pass),
NULL, 0, iter, p8inf))) {
if ((p8 = PKCS8_encrypt(pbe_nid, cipher,
p8pass, strlen(p8pass),
NULL, 0, iter, p8inf)) == NULL) {
BIO_printf(bio_err, "Error encrypting key\n");
ERR_print_errors(bio_err);
goto end;
@ -296,7 +296,7 @@ int pkcs8_main(int argc, char **argv)
goto end;
}
if (!(pkey = EVP_PKCS82PKEY(p8inf))) {
if ((pkey = EVP_PKCS82PKEY(p8inf)) == NULL) {
BIO_printf(bio_err, "Error converting key\n");
ERR_print_errors(bio_err);
goto end;


+ 1
- 1
apps/req.c View File

@ -962,7 +962,7 @@ static int build_subject(X509_REQ *req, char *subject, unsigned long chtype,
{
X509_NAME *n;
if (!(n = parse_name(subject, chtype, multirdn)))
if ((n = parse_name(subject, chtype, multirdn)) == NULL)
return 0;
if (!X509_REQ_set_subject_name(req, n)) {


+ 2
- 1
apps/s_client.c View File

@ -345,7 +345,8 @@ static int ssl_srp_verify_param_cb(SSL *s, void *arg)
{
SRP_ARG *srp_arg = (SRP_ARG *)arg;
BIGNUM *N = NULL, *g = NULL;
if (!(N = SSL_get_srp_N(s)) || !(g = SSL_get_srp_g(s)))
if (((N = SSL_get_srp_N(s)) == NULL) || ((g = SSL_get_srp_g(s)) == NULL))
return 0;
if (srp_arg->debug || srp_arg->msg || srp_arg->amp == 1) {
BIO_printf(bio_err, "SRP parameters:\n");


+ 6
- 6
apps/smime.c View File

@ -463,16 +463,16 @@ int smime_main(int argc, char **argv)
}
if (certfile) {
if (!(other = load_certs(certfile, FORMAT_PEM, NULL,
e, "certificate file"))) {
if ((other = load_certs(certfile, FORMAT_PEM, NULL,
e, "certificate file")) == NULL) {
ERR_print_errors(bio_err);
goto end;
}
}
if (recipfile && (operation == SMIME_DECRYPT)) {
if (!(recip = load_cert(recipfile, FORMAT_PEM, NULL,
e, "recipient certificate file"))) {
if ((recip = load_cert(recipfile, FORMAT_PEM, NULL,
e, "recipient certificate file")) == NULL) {
ERR_print_errors(bio_err);
goto end;
}
@ -515,7 +515,7 @@ int smime_main(int argc, char **argv)
}
if (contfile) {
BIO_free(indata);
if (!(indata = BIO_new_file(contfile, "rb"))) {
if ((indata = BIO_new_file(contfile, "rb")) == NULL) {
BIO_printf(bio_err, "Can't read content file %s\n", contfile);
goto end;
}
@ -527,7 +527,7 @@ int smime_main(int argc, char **argv)
goto end;
if (operation == SMIME_VERIFY) {
if (!(store = setup_verify(CAfile, CApath)))
if ((store = setup_verify(CAfile, CApath)) == NULL)
goto end;
X509_STORE_set_verify_cb(store, smime_cb);
if (vpmtouched)


+ 16
- 11
apps/srp.c View File

@ -516,10 +516,13 @@ int srp_main(int argc, char **argv)
row[DB_srptype] = BUF_strdup("v");
row[DB_srpgN] = BUF_strdup(gNid);
if (!row[DB_srpid] || !row[DB_srpgN] || !row[DB_srptype]
|| !row[DB_srpverifier] || !row[DB_srpsalt]
|| (userinfo &&
(!(row [DB_srpinfo] = BUF_strdup (userinfo))))
if ((row[DB_srpid] == NULL)
|| (row[DB_srpgN] == NULL)
|| (row[DB_srptype] == NULL)
|| (row[DB_srpverifier] == NULL)
|| (row[DB_srpsalt] == NULL)
|| (userinfo
&& ((row[DB_srpinfo] = BUF_strdup(userinfo)) == NULL))
|| !update_index(db, row)) {
OPENSSL_free(row[DB_srpid]);
OPENSSL_free(row[DB_srpgN]);
@ -596,10 +599,14 @@ int srp_main(int argc, char **argv)
row[DB_srptype][0] = 'v';
row[DB_srpgN] = BUF_strdup(gNid);
if (!row[DB_srpid] || !row[DB_srpgN] || !row[DB_srptype]
|| !row[DB_srpverifier] || !row[DB_srpsalt]
if (row[DB_srpid] == NULL
|| row[DB_srpgN] == NULL
|| row[DB_srptype] == NULL
|| row[DB_srpverifier] == NULL
|| row[DB_srpsalt] == NULL
|| (userinfo
&& (!(row[DB_srpinfo] = BUF_strdup(userinfo)))))
&& ((row[DB_srpinfo] = BUF_strdup(userinfo))
== NULL)))
goto end;
doupdatedb = 1;
@ -612,12 +619,10 @@ int srp_main(int argc, char **argv)
user);
errors++;
} else {
char **xpp =
sk_OPENSSL_PSTRING_value(db->db->data, userindex);
BIO_printf(bio_err, "user \"%s\" revoked. t\n", user);
char **xpp = sk_OPENSSL_PSTRING_value(db->db->data, userindex);
BIO_printf(bio_err, "user \"%s\" revoked. t\n", user);
xpp[DB_srptype][0] = 'R';
doupdatedb = 1;
}
}


+ 42
- 40
apps/ts.c View File

@ -381,7 +381,7 @@ static ASN1_OBJECT *txt2obj(const char *oid)
{
ASN1_OBJECT *oid_obj = NULL;
if (!(oid_obj = OBJ_txt2obj(oid, 0)))
if ((oid_obj = OBJ_txt2obj(oid, 0)) == NULL)
BIO_printf(bio_err, "cannot convert %s to OID\n", oid);
return oid_obj;
@ -398,8 +398,8 @@ static CONF *load_config_file(const char *configfile)
configfile = getenv("SSLEAY_CONF");
if (configfile &&
(!(conf = NCONF_new(NULL)) ||
NCONF_load(conf, configfile, &errorline) <= 0)) {
((conf = NCONF_new(NULL)) == NULL
|| NCONF_load(conf, configfile, &errorline) <= 0)) {
if (errorline <= 0)
BIO_printf(bio_err, "error loading the config file "
"'%s'\n", configfile);
@ -449,7 +449,8 @@ static int query_command(const char *data, char *digest, const EVP_MD *md,
query = d2i_TS_REQ_bio(in_bio, NULL);
} else {
/* Open the file if no explicit digest bytes were specified. */
if (!digest && !(data_bio = bio_open_default(data, "rb")))
if (digest == NULL
&& (data_bio = bio_open_default(data, "rb")) == NULL)
goto end;
query = create_query(data_bio, digest, md, policy, no_nonce, cert);
}
@ -496,11 +497,11 @@ static TS_REQ *create_query(BIO *data_bio, char *digest, const EVP_MD *md,
ASN1_INTEGER *nonce_asn1 = NULL;
/* Setting default message digest. */
if (!md && !(md = EVP_get_digestbyname("sha1")))
if (md == NULL && (md = EVP_get_digestbyname("sha1")) == NULL)
goto err;
/* Creating request object. */
if (!(ts_req = TS_REQ_new()))
if ((ts_req = TS_REQ_new()) == NULL)
goto err;
/* Setting version. */
@ -508,15 +509,15 @@ static TS_REQ *create_query(BIO *data_bio, char *digest, const EVP_MD *md,
goto err;
/* Creating and adding MSG_IMPRINT object. */
if (!(msg_imprint = TS_MSG_IMPRINT_new()))
if ((msg_imprint = TS_MSG_IMPRINT_new()) == NULL)
goto err;
/* Adding algorithm. */
if (!(algo = X509_ALGOR_new()))
if ((algo = X509_ALGOR_new()) == NULL)
goto err;
if (!(algo->algorithm = OBJ_nid2obj(EVP_MD_type(md))))
if ((algo->algorithm = OBJ_nid2obj(EVP_MD_type(md))) == NULL)
goto err;
if (!(algo->parameter = ASN1_TYPE_new()))
if ((algo->parameter = ASN1_TYPE_new()) == NULL)
goto err;
algo->parameter->type = V_ASN1_NULL;
if (!TS_MSG_IMPRINT_set_algo(msg_imprint, algo))
@ -532,13 +533,13 @@ static TS_REQ *create_query(BIO *data_bio, char *digest, const EVP_MD *md,
goto err;
/* Setting policy if requested. */
if (policy && !(policy_obj = txt2obj(policy)))
if (policy && (policy_obj = txt2obj(policy)) == NULL)
goto err;
if (policy_obj && !TS_REQ_set_policy_id(ts_req, policy_obj))
goto err;
/* Setting nonce if requested. */
if (!no_nonce && !(nonce_asn1 = create_nonce(NONCE_LENGTH)))
if (!no_nonce && (nonce_asn1 = create_nonce(NONCE_LENGTH)) == NULL)
goto err;
if (nonce_asn1 && !TS_REQ_set_nonce(ts_req, nonce_asn1))
goto err;
@ -615,8 +616,9 @@ static ASN1_INTEGER *create_nonce(int bits)
goto err;
/* Find the first non-zero byte and creating ASN1_INTEGER object. */
for (i = 0; i < len && !buf[i]; ++i) ;
if (!(nonce = ASN1_INTEGER_new()))
for (i = 0; i < len && !buf[i]; ++i)
continue;
if ((nonce = ASN1_INTEGER_new()) == NULL)
goto err;
OPENSSL_free(nonce->data);
/* Allocate at least one byte. */
@ -725,17 +727,17 @@ static TS_RESP *read_PKCS7(BIO *in_bio)
TS_STATUS_INFO *si = NULL;
/* Read PKCS7 object and extract the signed time stamp info. */
if (!(token = d2i_PKCS7_bio(in_bio, NULL)))
if ((token = d2i_PKCS7_bio(in_bio, NULL)) == NULL)
goto end;
if (!(tst_info = PKCS7_to_TS_TST_INFO(token)))
if ((tst_info = PKCS7_to_TS_TST_INFO(token)) == NULL)
goto end;
/* Creating response object. */
if (!(resp = TS_RESP_new()))
if ((resp = TS_RESP_new()) == NULL)
goto end;
/* Create granted status info. */
if (!(si = TS_STATUS_INFO_new()))
if ((si = TS_STATUS_INFO_new()) == NULL)
goto end;
if (!(ASN1_INTEGER_set(si->status, TS_STATUS_GRANTED)))
goto end;
@ -769,15 +771,15 @@ static TS_RESP *create_response(CONF *conf, const char *section, char *engine,
BIO *query_bio = NULL;
TS_RESP_CTX *resp_ctx = NULL;
if (!(query_bio = BIO_new_file(queryfile, "rb")))
if ((query_bio = BIO_new_file(queryfile, "rb")) == NULL)
goto end;
/* Getting TSA configuration section. */
if (!(section = TS_CONF_get_tsa_section(conf, section)))
if ((section = TS_CONF_get_tsa_section(conf, section)) == NULL)
goto end;
/* Setting up response generation context. */
if (!(resp_ctx = TS_RESP_CTX_new()))
if ((resp_ctx = TS_RESP_CTX_new()) == NULL)
goto end;
/* Setting serial number provider callback. */
@ -834,7 +836,7 @@ static TS_RESP *create_response(CONF *conf, const char *section, char *engine,
goto end;
/* Creating the response. */
if (!(response = TS_RESP_create_response(resp_ctx, query_bio)))
if ((response = TS_RESP_create_response(resp_ctx, query_bio)) == NULL)
goto end;
ret = 1;
@ -872,10 +874,10 @@ static ASN1_INTEGER *next_serial(const char *serialfile)
ASN1_INTEGER *serial = NULL;
BIGNUM *bn = NULL;
if (!(serial = ASN1_INTEGER_new()))
if ((serial = ASN1_INTEGER_new()) == NULL)
goto err;
if (!(in = BIO_new_file(serialfile, "r"))) {
if ((in = BIO_new_file(serialfile, "r")) == NULL) {
ERR_clear_error();
BIO_printf(bio_err, "Warning: could not open file %s for "
"reading, using serial number: 1\n", serialfile);
@ -888,13 +890,13 @@ static ASN1_INTEGER *next_serial(const char *serialfile)
serialfile);
goto err;
}
if (!(bn = ASN1_INTEGER_to_BN(serial, NULL)))
if ((bn = ASN1_INTEGER_to_BN(serial, NULL)) == NULL)
goto err;
ASN1_INTEGER_free(serial);
serial = NULL;
if (!BN_add_word(bn, 1))
goto err;
if (!(serial = BN_to_ASN1_INTEGER(bn, NULL)))
if ((serial = BN_to_ASN1_INTEGER(bn, NULL)) == NULL)
goto err;
}
ret = 1;
@ -913,7 +915,7 @@ static int save_ts_serial(const char *serialfile, ASN1_INTEGER *serial)
int ret = 0;
BIO *out = NULL;
if (!(out = BIO_new_file(serialfile, "w")))
if ((out = BIO_new_file(serialfile, "w")) == NULL)
goto err;
if (i2a_ASN1_INTEGER(out, serial) <= 0)
goto err;
@ -943,18 +945,18 @@ static int verify_command(char *data, char *digest, char *queryfile,
int ret = 0;
/* Decode the token (PKCS7) or response (TS_RESP) files. */
if (!(in_bio = BIO_new_file(in, "rb")))
if ((in_bio = BIO_new_file(in, "rb")) == NULL)
goto end;
if (token_in) {
if (!(token = d2i_PKCS7_bio(in_bio, NULL)))
if ((token = d2i_PKCS7_bio(in_bio, NULL)) == NULL)
goto end;
} else {
if (!(response = d2i_TS_RESP_bio(in_bio, NULL)))
if ((response = d2i_TS_RESP_bio(in_bio, NULL)) == NULL)
goto end;
}
if (!(verify_ctx = create_verify_ctx(data, digest, queryfile,
CApath, CAfile, untrusted)))
if ((verify_ctx = create_verify_ctx(data, digest, queryfile,
CApath, CAfile, untrusted)) == NULL)
goto end;
/* Checking the token or response against the request. */
@ -991,17 +993,17 @@ static TS_VERIFY_CTX *create_verify_ctx(char *data, char *digest,
int ret = 0;
if (data != NULL || digest != NULL) {
if (!(ctx = TS_VERIFY_CTX_new()))
if ((ctx = TS_VERIFY_CTX_new()) == NULL)
goto err;
ctx->flags = TS_VFY_VERSION | TS_VFY_SIGNER;
if (data != NULL) {
ctx->flags |= TS_VFY_DATA;
if (!(ctx->data = BIO_new_file(data, "rb")))
if ((ctx->data = BIO_new_file(data, "rb")) == NULL)
goto err;
} else if (digest != NULL) {
long imprint_len;
ctx->flags |= TS_VFY_IMPRINT;
if (!(ctx->imprint = string_to_hex(digest, &imprint_len))) {
if ((ctx->imprint = string_to_hex(digest, &imprint_len)) == NULL) {
BIO_printf(bio_err, "invalid digest string\n");
goto err;
}
@ -1013,11 +1015,11 @@ static TS_VERIFY_CTX *create_verify_ctx(char *data, char *digest,
* The request has just to be read, decoded and converted to a verify
* context object.
*/
if (!(input = BIO_new_file(queryfile, "rb")))
if ((input = BIO_new_file(queryfile, "rb")) == NULL)
goto err;
if (!(request = d2i_TS_REQ_bio(input, NULL)))
if ((request = d2i_TS_REQ_bio(input, NULL)) == NULL)
goto err;
if (!(ctx = TS_REQ_to_TS_VERIFY_CTX(request, NULL)))
if ((ctx = TS_REQ_to_TS_VERIFY_CTX(request, NULL)) == NULL)
goto err;
} else
return NULL;
@ -1026,11 +1028,11 @@ static TS_VERIFY_CTX *create_verify_ctx(char *data, char *digest,
ctx->flags |= TS_VFY_SIGNATURE;
/* Initialising the X509_STORE object. */
if (!(ctx->store = create_cert_store(CApath, CAfile)))
if ((ctx->store = create_cert_store(CApath, CAfile)) == NULL)
goto err;
/* Loading untrusted certificates. */
if (untrusted && !(ctx->certs = TS_CONF_load_certs(untrusted)))
if (untrusted && (ctx->certs = TS_CONF_load_certs(untrusted)) == NULL)
goto err;
ret = 1;


+ 1
- 1
apps/verify.c View File

@ -177,7 +177,7 @@ int verify_main(int argc, char **argv)
argc = opt_num_rest();
argv = opt_rest();
if (!(store = setup_verify(CAfile, CApath)))
if ((store = setup_verify(CAfile, CApath)) == NULL)
goto end;
X509_STORE_set_verify_cb(store, cb);


+ 1
- 3
apps/x509.c View File

@ -1021,11 +1021,9 @@ static int x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest,
}
if (sno)
bs = sno;
else if (!(bs = x509_load_serial(CAfile, serialfile, create)))
else if ((bs = x509_load_serial(CAfile, serialfile, create)) == NULL)
goto end;
/* if (!X509_STORE_add_cert(ctx,x)) goto end;*/
/*
* NOTE: this certificate can/should be self signed, unless it was a
* certificate request in which case it is not.


+ 1
- 1
crypto/asn1/a_mbstr.c View File

@ -235,7 +235,7 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
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);


+ 2
- 2
crypto/asn1/a_time.c View File

@ -116,8 +116,8 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t,
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;


+ 9
- 20
crypto/asn1/asn1_gen.c View File

@ -492,15 +492,12 @@ static ASN1_TYPE *asn1_multi(int utype, const char *section, X509V3_CTX *cnf,
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 int asn1_str2tag(const char *tagstr, int len)
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 @@ static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype)
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 @@ static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype)
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 @@ static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype)
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 @@ static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype)
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 @@ static ASN1_TYPE *asn1_str2type(const char *str, int format, int utype)
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)


+ 17
- 12
crypto/asn1/asn_mime.c View File

@ -180,7 +180,8 @@ static ASN1_VALUE *b64_read_asn1(BIO *bio, const ASN1_ITEM *it)
{
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 @@ ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it)
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 @@ ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it)
/* 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 @@ ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it)
/* 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 @@ ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it)
}
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 @@ ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it)
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 @@ int SMIME_text(BIO *in, BIO *out)
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 @@ static MIME_HEADER *mime_hdr_new(char *name, char *value)
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 @@ static MIME_HEADER *mime_hdr_new(char *name, char *value)
}
}
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 @@ static MIME_HEADER *mime_hdr_new(char *name, char *value)
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;


+ 2
- 1
crypto/asn1/asn_moid.c View File

@ -76,8 +76,9 @@ static int oid_module_init(CONF_IMODULE *md, const CONF *cnf)
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;
}


+ 2
- 1
crypto/asn1/asn_mstbl.c View File

@ -70,8 +70,9 @@ static int stbl_module_init(CONF_IMODULE *md, const CONF *cnf)
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;
}


+ 4
- 4
crypto/asn1/asn_pack.c View File

@ -67,8 +67,8 @@ ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_STRING **oct)
{
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 @@ ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_STRING **oct)
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 *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it)
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;
}

+ 8
- 9
crypto/asn1/p5_pbev2.c View File

@ -106,14 +106,13 @@ X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter,
}
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 @@ X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter,
/* 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 @@ X509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen,
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 @@ X509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen,
/* 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;


+ 14
- 11
crypto/asn1/x_x509a.c View File

@ -84,9 +84,9 @@ IMPLEMENT_ASN1_FUNCTIONS(X509_CERT_AUX)
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 @@ int X509_alias_set1(X509 *x, unsigned char *name, int len)
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 @@ int X509_keyid_set1(X509 *x, unsigned char *id, int len)
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 @@ int X509_add1_trust_object(X509 *x, ASN1_OBJECT *obj)
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 @@ int X509_add1_reject_object(X509 *x, ASN1_OBJECT *obj)
{
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);
}


+ 1
- 1
crypto/bio/bf_nbio.c View File

@ -102,7 +102,7 @@ static int nbiof_new(BIO *bi)
{
NBIO_TEST *nt;
if (!(nt = OPENSSL_malloc(sizeof(*nt))))
if ((nt = OPENSSL_malloc(sizeof(*nt))) == NULL)
return (0);
nt->lrn = -1;
nt->lwn = -1;


+ 1
- 1
crypto/bio/bss_conn.c View File

@ -269,7 +269,7 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
}
if (cb != NULL) {
if (!(ret = cb((BIO *)b, c->state, ret)))
if ((ret = cb((BIO *)b, c->state, ret)) == 0)
goto end;
}
}


+ 1
- 1
crypto/bio/bss_dgram.c View File

@ -1406,7 +1406,7 @@ static int dgram_sctp_write(BIO *b, const char *in, int inl)
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;
}


+ 2
- 2
crypto/bio/bss_mem.c View File

@ -97,12 +97,12 @@ BIO *BIO_new_mem_buf(void *buf, int len)
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;


+ 2
- 1
crypto/cms/cms_smime.c View File

@ -801,7 +801,8 @@ int CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont, unsigned int flags)
{
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;
}


+ 1
- 1
crypto/conf/conf_def.c View File

@ -357,7 +357,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
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;
}


+ 4
- 4
crypto/conf/conf_lib.c View File

@ -118,7 +118,7 @@ LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp,
{
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 @@ int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out)
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 @@ int NCONF_load_fp(CONF *conf, FILE *fp, long *eline)
{
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 @@ int NCONF_dump_fp(const CONF *conf, FILE *out)
{
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;
}


+ 11
- 10
crypto/dh/dh_ameth.c View File

@ -119,18 +119,18 @@ static int dh_pub_decode(EVP_PKEY *pkey, X509_PUBKEY *pubkey)
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 @@ static int dh_priv_decode(EVP_PKEY *pkey, PKCS8_PRIV_KEY_INFO *p8)
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;