Also added blanks lines after declarations in a couple of places.
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9916)
}
pkey = X509_get_pubkey(X509_OBJECT_get0_X509(xobj));
X509_OBJECT_free(xobj);
- if (!pkey) {
+ if (pkey == NULL) {
BIO_printf(bio_err, "Error getting CRL issuer public key\n");
goto end;
}
if (!newcrl)
goto end;
pkey = load_key(keyfile, keyformat, 0, NULL, NULL, "CRL signing key");
- if (!pkey) {
+ if (pkey == NULL) {
X509_CRL_free(newcrl);
goto end;
}
}
pbio = BIO_new_file(file, "r");
- if (!pbio) {
+ if (pbio == NULL) {
BIO_printf(bio_err, "Can't open parameter file %s\n", file);
return 0;
}
pkey = PEM_read_bio_Parameters(pbio, NULL);
BIO_free(pbio);
- if (!pkey) {
+ if (pkey == NULL) {
BIO_printf(bio_err, "Error reading parameter file %s\n", file);
return 0;
}
/* Skip whitespace. */
while (*p && isspace(_UC(*p)))
p++;
- if (!*p)
+ if (*p == '\0')
break;
/* The start of something good :-) */
#endif
} else if (strcmp(arg, "stdin") == 0) {
pwdbio = dup_bio_in(FORMAT_TEXT);
- if (!pwdbio) {
+ if (pwdbio == NULL) {
BIO_printf(bio_err, "Can't open BIO for stdin\n");
return NULL;
}
if (PKCS12_verify_mac(p12, "", 0) || PKCS12_verify_mac(p12, NULL, 0)) {
pass = "";
} else {
- if (!pem_cb)
+ if (pem_cb == NULL)
pem_cb = (pem_password_cb *)password_callback;
len = pem_cb(tpass, PEM_BUFSIZE, 0, cb_data);
if (len < 0) {
p12 = PKCS12_create(cpass, name, key, ucert, certs,
key_pbe, cert_pbe, iter, -1, keytype);
- if (!p12) {
+ if (p12 == NULL) {
ERR_print_errors(bio_err);
goto export_end;
}
newreq = 1;
break;
case OPT_PKEYOPT:
- if (!pkeyopts)
+ if (pkeyopts == NULL)
pkeyopts = sk_OPENSSL_STRING_new_null();
- if (!pkeyopts || !sk_OPENSSL_STRING_push(pkeyopts, opt_arg()))
+ if (pkeyopts == NULL
+ || !sk_OPENSSL_STRING_push(pkeyopts, opt_arg()))
goto opthelp;
break;
case OPT_SIGOPT:
md_value_len = EVP_MD_size(md);
} else {
long digest_len;
+
*md_value = OPENSSL_hexstr2buf(digest, &digest_len);
- if (!*md_value || md_value_len != digest_len) {
+ if (*md_value == NULL || md_value_len != digest_len) {
OPENSSL_free(*md_value);
*md_value = NULL;
BIO_printf(bio_err, "bad digest, %d bytes "
char *end;
if (strncmp(p, "MASK:", 5) == 0) {
- if (!p[5])
+ if (p[5] == '\0')
return 0;
mask = strtoul(p + 5, &end, 0);
if (*end)
goto err;
}
if (mdnid == NID_undef) {
- if (!pkey->ameth || !pkey->ameth->item_verify) {
+ if (pkey->ameth == NULL || pkey->ameth->item_verify == NULL) {
ASN1err(ASN1_F_ASN1_ITEM_VERIFY,
ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM);
goto err;
{
EVP_PKEY_ASN1_METHOD tmp;
const EVP_PKEY_ASN1_METHOD *t = &tmp, **ret;
+
tmp.pkey_id = type;
if (app_methods) {
int idx;
return sk_EVP_PKEY_ASN1_METHOD_value(app_methods, idx);
}
ret = OBJ_bsearch_ameth(&t, standard_methods, OSSL_NELEM(standard_methods));
- if (!ret || !*ret)
+ if (ret == NULL || *ret == NULL)
return NULL;
return *ret;
}
if (strcmp(hdr->value, "multipart/signed") == 0) {
/* Split into two parts */
prm = mime_param_find(hdr, "boundary");
- if (!prm || !prm->param_value) {
+ if (prm == NULL || prm->param_value == NULL) {
sk_MIME_HEADER_pop_free(headers, mime_hdr_free);
ASN1err(ASN1_F_SMIME_READ_ASN1, ASN1_R_NO_MULTIPART_BOUNDARY);
return NULL;
unsigned char *p;
int derlen;
- if (!parg)
+ if (parg == NULL)
return 0;
ndef_aux = *(NDEF_SUPPORT **)parg;
*pbuf = p;
derlen = ASN1_item_ndef_i2d(ndef_aux->val, &p, ndef_aux->it);
- if (!*ndef_aux->boundary)
+ if (*ndef_aux->boundary == NULL)
return 0;
*plen = *ndef_aux->boundary - *pbuf;
{
NDEF_SUPPORT *ndef_aux;
- if (!parg)
+ if (parg == NULL)
return 0;
ndef_aux = *(NDEF_SUPPORT **)parg;
const ASN1_AUX *aux;
ASN1_STREAM_ARG sarg;
- if (!parg)
+ if (parg == NULL)
return 0;
ndef_aux = *(NDEF_SUPPORT **)parg;
*pbuf = p;
derlen = ASN1_item_ndef_i2d(ndef_aux->val, &p, ndef_aux->it);
- if (!*ndef_aux->boundary)
+ if (*ndef_aux->boundary == NULL)
return 0;
*pbuf = *ndef_aux->boundary;
*plen = derlen - (*ndef_aux->boundary - ndef_aux->derbuf);
EVP_PKEY *tmp;
PKCS8_PRIV_KEY_INFO *p8 = NULL;
p8 = d2i_PKCS8_PRIV_KEY_INFO(NULL, &p, length);
- if (!p8)
+ if (p8 == NULL)
goto err;
tmp = EVP_PKCS82PKEY(p8);
PKCS8_PRIV_KEY_INFO_free(p8);
EVP_PKEY *ret;
sk_ASN1_TYPE_pop_free(inkey, ASN1_TYPE_free);
- if (!p8) {
+ if (p8 == NULL) {
ASN1err(ASN1_F_D2I_AUTOPRIVATEKEY,
ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE);
return NULL;
pbe2->keyfunc = PKCS5_pbkdf2_set(iter, salt, saltlen, prf_nid, keylen);
- if (!pbe2->keyfunc)
+ if (pbe2->keyfunc == NULL)
goto merr;
/* Now set up top level AlgorithmIdentifier */
BIO_printf(out, " Public Key Algorithm: %s\n",
(i == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(i));
pkey = X509_PUBKEY_get(spki->spkac->pubkey);
- if (!pkey)
+ if (pkey == NULL)
BIO_printf(out, " Unable to load public key\n");
else {
EVP_PKEY_print_public(out, pkey, 4, NULL);
{
ASN1_TLC c;
ASN1_VALUE *ptmpval = NULL;
- if (!pval)
+
+ if (pval == NULL)
pval = &ptmpval;
asn1_tlc_clear_nc(&c);
if (ASN1_item_ex_d2i(pval, in, len, it, -1, 0, 0, &c) > 0)
int otag;
int ret = 0;
ASN1_VALUE **pchptr;
- if (!pval)
+
+ if (pval == NULL)
return 0;
if (aux && aux->asn1_cb)
asn1_cb = aux->asn1_cb;
goto err;
}
- if (!*pval && !ASN1_item_ex_new(pval, it)) {
+ if (*pval == NULL && !ASN1_item_ex_new(pval, it)) {
ASN1err(ASN1_F_ASN1_ITEM_EMBED_D2I, ERR_R_NESTED_ASN1_ERROR);
goto err;
}
return 0;
} else if (ret == -1)
return -1;
- if (!*val)
+ if (*val == NULL)
*val = (ASN1_VALUE *)sk_ASN1_VALUE_new_null();
else {
/*
}
}
- if (!*val) {
+ if (*val == NULL) {
ASN1err(ASN1_F_ASN1_TEMPLATE_NOEXP_D2I, ERR_R_MALLOC_FAILURE);
goto err;
}
BUF_MEM buf = { 0, NULL, 0, 0 };
const unsigned char *cont = NULL;
long len;
- if (!pval) {
+
+ if (pval == NULL) {
ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_ILLEGAL_NULL);
return 0; /* Should never happen */
}
return pf->prim_c2i(pval, cont, len, utype, free_cont, it);
/* If ANY type clear type and set pointer to internal value */
if (it->utype == V_ASN1_ANY) {
- if (!*pval) {
+ if (*pval == NULL) {
typ = ASN1_TYPE_new();
if (typ == NULL)
goto err;
goto err;
}
/* All based on ASN1_STRING and handled the same */
- if (!*pval) {
+ if (*pval == NULL) {
stmp = ASN1_STRING_type_new(utype);
if (stmp == NULL) {
ASN1err(ASN1_F_ASN1_EX_C2I, ERR_R_MALLOC_FAILURE);
static int asn1_check_eoc(const unsigned char **in, long len)
{
const unsigned char *p;
+
if (len < 2)
return 0;
p = *in;
- if (!p[0] && !p[1]) {
+ if (p[0] == '\0' && p[1] == '\0') {
*in += 2;
return 1;
}
static int asn1_item_flags_i2d(const ASN1_VALUE *val, unsigned char **out,
const ASN1_ITEM *it, int flags)
{
- if (out && !*out) {
+ if (out != NULL && *out == NULL) {
unsigned char *p, *buf;
int len;
const ASN1_AUX *aux = it->funcs;
ASN1_aux_const_cb *asn1_cb = NULL;
- if ((it->itype != ASN1_ITYPE_PRIMITIVE) && !*pval)
+ if ((it->itype != ASN1_ITYPE_PRIMITIVE) && *pval == NULL)
return 0;
if (aux != NULL) {
int skcontlen, sklen;
const ASN1_VALUE *skitem;
- if (!*pval)
+ if (*pval == NULL)
return 0;
if (flags & ASN1_TFLG_SET_OF) {
/* Should type be omitted? */
if ((it->itype != ASN1_ITYPE_PRIMITIVE)
|| (it->utype != V_ASN1_BOOLEAN)) {
- if (!*pval)
+ if (*pval == NULL)
return -1;
}
ASN1_aux_cb *asn1_cb;
int i;
- if (!pval)
+ if (pval == NULL)
return;
- if ((it->itype != ASN1_ITYPE_PRIMITIVE) && !*pval)
+ if ((it->itype != ASN1_ITYPE_PRIMITIVE) && *pval == NULL)
return;
if (aux && aux->asn1_cb)
asn1_cb = aux->asn1_cb;
utype = typ->type;
pval = &typ->value.asn1_value;
- if (!*pval)
+ if (*pval == NULL)
return;
} else if (it->itype == ASN1_ITYPE_MSTRING) {
utype = -1;
- if (!*pval)
+ if (*pval == NULL)
return;
} else {
utype = it->utype;
- if ((utype != V_ASN1_BOOLEAN) && !*pval)
+ if ((utype != V_ASN1_BOOLEAN) && *pval == NULL)
return;
}
static void bn_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
{
- if (!*pval)
+ if (*pval == NULL)
return;
if (it->size & BN_SENSITIVE)
BN_clear_free((BIGNUM *)*pval);
{
BIGNUM *bn;
int pad;
- if (!*pval)
+ if (*pval == NULL)
return -1;
bn = (BIGNUM *)*pval;
/* If MSB set in an octet we need a padding byte */
int ret;
BIGNUM *bn;
- if (!*pval && !bn_secure_new(pval, it))
+ if (*pval == NULL && !bn_secure_new(pval, it))
return 0;
ret = bn_c2i(pval, cont, len, utype, free_cont, it);
{
ASYNC_JOB *job;
- if (!pool || !pool->jobs)
+ if (pool == NULL || pool->jobs == NULL)
return;
do {
bn_check_top(a);
- if (!p[0]) {
+ if (p[0] == 0) {
/* reduction mod 1 => return 0 */
BN_zero(r);
return 1;
bn_check_top(a);
- if (!p[0]) {
+ if (p[0] == 0) {
/* reduction mod 1 => return 0 */
BN_zero(r);
return 1;
bn_check_top(a_);
- if (!p[0]) {
+ if (p[0] == 0) {
/* reduction mod 1 => return 0 */
BN_zero(r);
return 1;
pkey = ri->d.ktri->pkey;
else if (ri->type == CMS_RECIPINFO_AGREE) {
EVP_PKEY_CTX *pctx = ri->d.kari->pctx;
- if (!pctx)
+
+ if (pctx == NULL)
return 0;
pkey = EVP_PKEY_CTX_get0_pkey(pctx);
- if (!pkey)
+ if (pkey == NULL)
return 0;
} else
return 0;
- if (!pkey->ameth || !pkey->ameth->pkey_ctrl)
+ if (pkey->ameth == NULL || pkey->ameth->pkey_ctrl == NULL)
return 1;
i = pkey->ameth->pkey_ctrl(pkey, ASN1_PKEY_CTRL_CMS_ENVELOPE, cmd, ri);
if (i == -2) {
goto merr;
pk = X509_get0_pubkey(recip);
- if (!pk) {
+ if (pk == NULL) {
CMSerr(CMS_F_CMS_ADD1_RECIPIENT_CERT, CMS_R_ERROR_GETTING_PUBLIC_KEY);
goto err;
}
/* Extract and decode receipt content */
pcont = CMS_get0_content(cms);
- if (!pcont || !*pcont) {
+ if (pcont == NULL || *pcont == NULL) {
CMSerr(CMS_F_CMS_RECEIPT_VERIFY, CMS_R_NO_CONTENT);
goto err;
}
EVP_PKEY_CTX_free(kari->pctx);
kari->pctx = NULL;
- if (!pk)
+ if (pk == NULL)
return 1;
pctx = EVP_PKEY_CTX_new(pk, NULL);
- if (!pctx || EVP_PKEY_derive_init(pctx) <= 0)
+ if (pctx == NULL || EVP_PKEY_derive_init(pctx) <= 0)
goto err;
kari->pctx = pctx;
return 1;
EVP_PKEY_CTX *pctx = NULL;
EVP_PKEY *ekey = NULL;
int rv = 0;
+
pctx = EVP_PKEY_CTX_new(pk, NULL);
- if (!pctx)
+ if (pctx == NULL)
goto err;
if (EVP_PKEY_keygen_init(pctx) <= 0)
goto err;
goto err;
EVP_PKEY_CTX_free(pctx);
pctx = EVP_PKEY_CTX_new(ekey, NULL);
- if (!pctx)
+ if (pctx == NULL)
goto err;
if (EVP_PKEY_derive_init(pctx) <= 0)
goto err;
BIO *cms_content_bio(CMS_ContentInfo *cms)
{
ASN1_OCTET_STRING **pos = CMS_get0_content(cms);
- if (!pos)
+
+ if (pos == NULL)
return NULL;
/* If content detached data goes nowhere: create NULL BIO */
- if (!*pos)
+ if (*pos == NULL)
return BIO_new(BIO_s_null());
/*
* If content not detached and created return memory BIO
*/
- if (!*pos || ((*pos)->flags == ASN1_STRING_FLAG_CONT))
+ if (*pos == NULL || ((*pos)->flags == ASN1_STRING_FLAG_CONT))
return BIO_new(BIO_s_mem());
/* Else content was read in: return read only BIO for it */
return BIO_new_mem_buf((*pos)->data, (*pos)->length);
int CMS_dataFinal(CMS_ContentInfo *cms, BIO *cmsbio)
{
ASN1_OCTET_STRING **pos = CMS_get0_content(cms);
- if (!pos)
+
+ if (pos == NULL)
return 0;
/* If embedded content find memory BIO and set content */
if (*pos && ((*pos)->flags & ASN1_STRING_FLAG_CONT)) {
int CMS_set1_eContentType(CMS_ContentInfo *cms, const ASN1_OBJECT *oid)
{
ASN1_OBJECT **petype, *etype;
+
petype = cms_get0_econtent_type(cms);
- if (!petype)
+ if (petype == NULL)
return 0;
- if (!oid)
+ if (oid == NULL)
return 1;
etype = OBJ_dup(oid);
- if (!etype)
+ if (etype == NULL)
return 0;
ASN1_OBJECT_free(*petype);
*petype = etype;
int CMS_is_detached(CMS_ContentInfo *cms)
{
ASN1_OCTET_STRING **pos;
+
pos = CMS_get0_content(cms);
- if (!pos)
+ if (pos == NULL)
return -1;
- if (*pos)
+ if (*pos != NULL)
return 0;
return 1;
}
int CMS_set_detached(CMS_ContentInfo *cms, int detached)
{
ASN1_OCTET_STRING **pos;
+
pos = CMS_get0_content(cms);
- if (!pos)
+ if (pos == NULL)
return 0;
if (detached) {
ASN1_OCTET_STRING_free(*pos);
{
STACK_OF(CMS_CertificateChoices) **pcerts;
CMS_CertificateChoices *cch;
+
pcerts = cms_get0_certificate_choices(cms);
- if (!pcerts)
+ if (pcerts == NULL)
return NULL;
- if (!*pcerts)
+ if (*pcerts == NULL)
*pcerts = sk_CMS_CertificateChoices_new_null();
- if (!*pcerts)
+ if (*pcerts == NULL)
return NULL;
cch = M_ASN1_new_of(CMS_CertificateChoices);
if (!cch)
CMS_CertificateChoices *cch;
STACK_OF(CMS_CertificateChoices) **pcerts;
int i;
+
pcerts = cms_get0_certificate_choices(cms);
- if (!pcerts)
+ if (pcerts == NULL)
return 0;
for (i = 0; i < sk_CMS_CertificateChoices_num(*pcerts); i++) {
cch = sk_CMS_CertificateChoices_value(*pcerts, i);
{
STACK_OF(CMS_RevocationInfoChoice) **pcrls;
CMS_RevocationInfoChoice *rch;
+
pcrls = cms_get0_revocation_choices(cms);
- if (!pcrls)
+ if (pcrls == NULL)
return NULL;
- if (!*pcrls)
+ if (*pcrls == NULL)
*pcrls = sk_CMS_RevocationInfoChoice_new_null();
- if (!*pcrls)
+ if (*pcrls == NULL)
return NULL;
rch = M_ASN1_new_of(CMS_RevocationInfoChoice);
- if (!rch)
+ if (rch == NULL)
return NULL;
if (!sk_CMS_RevocationInfoChoice_push(*pcrls, rch)) {
M_ASN1_free_of(rch, CMS_RevocationInfoChoice);
CMS_CertificateChoices *cch;
STACK_OF(CMS_CertificateChoices) **pcerts;
int i;
+
pcerts = cms_get0_certificate_choices(cms);
- if (!pcerts)
+ if (pcerts == NULL)
return NULL;
for (i = 0; i < sk_CMS_CertificateChoices_num(*pcerts); i++) {
cch = sk_CMS_CertificateChoices_value(*pcerts, i);
STACK_OF(CMS_RevocationInfoChoice) **pcrls;
CMS_RevocationInfoChoice *rch;
int i;
+
pcrls = cms_get0_revocation_choices(cms);
- if (!pcrls)
+ if (pcrls == NULL)
return NULL;
for (i = 0; i < sk_CMS_RevocationInfoChoice_num(*pcrls); i++) {
rch = sk_CMS_RevocationInfoChoice_value(*pcrls, i);
pwri->keyDerivationAlgorithm = PKCS5_pbkdf2_set(iter, NULL, 0, -1, -1);
- if (!pwri->keyDerivationAlgorithm)
+ if (pwri->keyDerivationAlgorithm == NULL)
goto err;
CMS_RecipientInfo_set0_password(ri, pass, passlen);
pwri = ri->d.pwri;
- if (!pwri->pass) {
+ if (pwri->pass == NULL) {
CMSerr(CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT, CMS_R_NO_PASSWORD);
return 0;
}
{
EVP_PKEY *pkey = si->pkey;
int i;
- if (!pkey->ameth || !pkey->ameth->pkey_ctrl)
+ if (pkey->ameth == NULL || pkey->ameth->pkey_ctrl == NULL)
return 1;
i = pkey->ameth->pkey_ctrl(pkey, ASN1_PKEY_CTRL_CMS_SIGN, cmd, si);
if (i == -2) {
static int check_content(CMS_ContentInfo *cms)
{
ASN1_OCTET_STRING **pos = CMS_get0_content(cms);
- if (!pos || !*pos) {
+
+ if (pos == NULL || *pos == NULL) {
CMSerr(CMS_F_CHECK_CONTENT, CMS_R_NO_CONTENT);
return 0;
}
static void do_free_upto(BIO *f, BIO *upto)
{
- if (upto) {
+ if (upto != NULL) {
BIO *tbio;
do {
tbio = BIO_pop(f);
BIO_free(f);
f = tbio;
- }
- while (f && f != upto);
+ } while (f != NULL && f != upto);
} else
BIO_free_all(f);
}
flags &= ~(CMS_STREAM | CMS_TEXT);
/* Not really detached but avoids content being allocated */
flags |= CMS_PARTIAL | CMS_BINARY | CMS_DETACHED;
- if (!pkey || !signcert) {
+ if (pkey == NULL || signcert == NULL) {
CMSerr(CMS_F_CMS_SIGN_RECEIPT, CMS_R_NO_KEY_OR_CERT);
return NULL;
}
{
int r;
BIO *cont;
+
if (OBJ_obj2nid(CMS_get0_type(cms)) != NID_pkcs7_enveloped) {
CMSerr(CMS_F_CMS_DECRYPT, CMS_R_TYPE_NOT_ENVELOPED_DATA);
return 0;
cms->d.envelopedData->encryptedContentInfo->havenocert = 1;
else
cms->d.envelopedData->encryptedContentInfo->havenocert = 0;
- if (!pk && !cert && !dcont && !out)
+ if (pk == NULL && cert == NULL && dcont == NULL && out == NULL)
return 1;
- if (pk && !CMS_decrypt_set1_pkey(cms, pk, cert))
+ if (pk != NULL && !CMS_decrypt_set1_pkey(cms, pk, cert))
return 0;
cont = CMS_dataInit(cms, dcont);
- if (!cont)
+ if (cont == NULL)
return 0;
r = cms_copy_content(out, cont, flags);
do_free_upto(cont, dcont);
const char *path = NULL;
int errcode = 0;
CONF_MODULE *md;
+
/* Look for alternative path in module section */
path = NCONF_get_string(cnf, value, "path");
- if (!path) {
+ if (path == NULL) {
ERR_clear_error();
path = name;
}
dso = DSO_load(NULL, path, NULL, 0);
- if (!dso) {
+ if (dso == NULL) {
errcode = CONF_R_ERROR_LOADING_DSO;
goto err;
}
ifunc = (conf_init_func *)DSO_bind_func(dso, DSO_mod_init_name);
- if (!ifunc) {
+ if (ifunc == NULL) {
errcode = CONF_R_MISSING_INIT_FUNCTION;
goto err;
}
/* All OK, add module */
md = module_add(dso, name, ifunc, ffunc);
- if (!md)
+ if (md == NULL)
goto err;
return md;
lstart++;
}
p = strchr(lstart, sep);
- if (p == lstart || !*lstart)
+ if (p == lstart || *lstart == '\0')
ret = list_cb(NULL, 0, arg);
else {
if (p)
ptype = V_ASN1_SEQUENCE;
pub_key = BN_to_ASN1_INTEGER(dh->pub_key, NULL);
- if (!pub_key)
+ if (pub_key == NULL)
goto err;
penclen = i2d_ASN1_INTEGER(pub_key, &penc);
const ASN1_STRING *pstr;
const X509_ALGOR *palg;
ASN1_INTEGER *privkey = NULL;
-
DH *dh = NULL;
if (!PKCS8_pkey_get0(NULL, &p, &pklen, &palg, p8))
/* Get private key into integer */
prkey = BN_to_ASN1_INTEGER(pkey->pkey.dh->priv_key, NULL);
- if (!prkey) {
+ if (prkey == NULL) {
DHerr(DH_F_DH_PRIV_ENCODE, DH_R_BN_ERROR);
goto err;
}
goto err;
pk = EVP_PKEY_CTX_get0_pkey(pctx);
- if (!pk)
+ if (pk == NULL)
goto err;
if (pk->type != EVP_PKEY_DHX)
goto err;
/* We have parameters now set public key */
plen = ASN1_STRING_length(pubkey);
p = ASN1_STRING_get0_data(pubkey);
- if (!p || !plen)
+ if (p == NULL || plen == 0)
goto err;
if ((public_key = d2i_ASN1_INTEGER(NULL, &p, plen)) == NULL) {
{
EVP_PKEY_CTX *pctx;
pctx = CMS_RecipientInfo_get0_pkey_ctx(ri);
- if (!pctx)
+
+ if (pctx == NULL)
return 0;
/* See if we need to set peer key */
if (!EVP_PKEY_CTX_get0_peerkey(pctx)) {
int rv = 0;
int kdf_type, wrap_nid;
const EVP_MD *kdf_md;
+
pctx = CMS_RecipientInfo_get0_pkey_ctx(ri);
- if (!pctx)
+ if (pctx == NULL)
return 0;
/* Get ephemeral key */
pkey = EVP_PKEY_CTX_get0_pkey(pctx);
/* Is everything uninitialised? */
if (aoid == OBJ_nid2obj(NID_undef)) {
ASN1_INTEGER *pubk = BN_to_ASN1_INTEGER(pkey->pkey.dh->pub_key, NULL);
- if (!pubk)
+
+ if (pubk == NULL)
goto err;
/* Set the key */
*/
penc = NULL;
penclen = i2d_X509_ALGOR(wrap_alg, &penc);
- if (!penc || !penclen)
+ if (penc == NULL || penclen == 0)
goto err;
wrap_str = ASN1_STRING_new();
if (wrap_str == NULL)
static int pkey_dh_copy(EVP_PKEY_CTX *dst, const EVP_PKEY_CTX *src)
{
DH_PKEY_CTX *dctx, *sctx;
+
if (!pkey_dh_init(dst))
return 0;
sctx = src->data;
unsigned char *dp = NULL;
int dplen;
- if (!pkey->pkey.dsa || !pkey->pkey.dsa->priv_key) {
+ if (pkey->pkey.dsa == NULL|| pkey->pkey.dsa->priv_key == NULL) {
DSAerr(DSA_F_DSA_PRIV_ENCODE, DSA_R_MISSING_PARAMETERS);
goto err;
}
/* Get private key into integer */
prkey = BN_to_ASN1_INTEGER(pkey->pkey.dsa->priv_key, NULL);
- if (!prkey) {
+ if (prkey == NULL) {
DSAerr(DSA_F_DSA_PRIV_ENCODE, DSA_R_BN_ERROR);
goto err;
}
eckey = eckey_type2param(ptype, pval);
- if (!eckey)
+ if (eckey == NULL)
goto ecliberr;
/* We have parameters now set private key */
const EC_GROUP *grp;
EVP_PKEY *pk;
pk = EVP_PKEY_CTX_get0_pkey(pctx);
- if (!pk)
+ if (pk == NULL)
goto err;
grp = EC_KEY_get0_group(pk->pkey.ec);
ecpeer = EC_KEY_new();
/* We have parameters now set public key */
plen = ASN1_STRING_length(pubkey);
p = ASN1_STRING_get0_data(pubkey);
- if (!p || !plen)
+ if (p == NULL || plen == 0)
goto err;
if (!o2i_ECPublicKey(&ecpeer, &p, plen))
goto err;
int curve_name = NID_undef;
BN_CTX *ctx = NULL;
- if (!params->fieldID || !params->fieldID->fieldType ||
- !params->fieldID->p.ptr) {
+ if (params->fieldID == NULL
+ || params->fieldID->fieldType == NULL
+ || params->fieldID->p.ptr == NULL) {
ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);
goto err;
}
* encoded them incorrectly, so we must accept any length for backwards
* compatibility.
*/
- if (!params->curve || !params->curve->a ||
- !params->curve->a->data || !params->curve->b ||
- !params->curve->b->data) {
+ if (params->curve == NULL
+ || params->curve->a == NULL || params->curve->a->data == NULL
+ || params->curve->b == NULL || params->curve->b->data == NULL) {
ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);
goto err;
}
X9_62_PENTANOMIAL *penta;
penta = char_two->p.ppBasis;
- if (!penta) {
+ if (penta == NULL) {
ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);
goto err;
}
else if (tmp == NID_X9_62_prime_field) {
/* we have a curve over a prime field */
/* extract the prime number */
- if (!params->fieldID->p.prime) {
+ if (params->fieldID->p.prime == NULL) {
ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);
goto err;
}
ret->seed_len = params->curve->seed->length;
}
- if (!params->order || !params->base || !params->base->data) {
+ if (params->order == NULL
+ || params->base == NULL
+ || params->base->data == NULL) {
ECerr(EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS, EC_R_ASN1_ERROR);
goto err;
}
void EC_POINT_free(EC_POINT *point)
{
- if (!point)
+ if (point == NULL)
return;
if (point->meth->point_finish != 0)
void EC_POINT_clear_free(EC_POINT *point)
{
- if (!point)
+ if (point == NULL)
return;
if (point->meth->point_clear_finish != 0)
return 1;
case DYNAMIC_CMD_DIR_ADD:
/* a NULL 'p' or a string of zero-length is the same thing */
- if (!p || (strlen((const char *)p) < 1)) {
+ if (p == NULL || (strlen((const char *)p) < 1)) {
ENGINEerr(ENGINE_F_DYNAMIC_CTRL, ENGINE_R_INVALID_ARGUMENT);
return 0;
}
EVP_PKEY_HMAC,
0
};
- if (!pmeth) {
+
+ if (pmeth == NULL) {
*nids = ossl_pkey_nids;
return 1;
}
return 0;
}
pkey = e->load_privkey(e, key_id, ui_method, callback_data);
- if (!pkey) {
+ if (pkey == NULL) {
ENGINEerr(ENGINE_F_ENGINE_LOAD_PRIVATE_KEY,
ENGINE_R_FAILED_LOADING_PRIVATE_KEY);
return 0;
return 0;
}
pkey = e->load_pubkey(e, key_id, ui_method, callback_data);
- if (!pkey) {
+ if (pkey == NULL) {
ENGINEerr(ENGINE_F_ENGINE_LOAD_PUBLIC_KEY,
ENGINE_R_FAILED_LOADING_PUBLIC_KEY);
return 0;
static void int_cleanup_cb_doall(ENGINE_PILE *p)
{
- if (!p)
+ if (p == NULL)
return;
sk_ENGINE_free(p->sk);
if (p->funct)
r = ERR_GET_REASON(e);
d.error = ERR_PACK(l, 0, r);
p = int_err_get_item(&d);
- if (!p) {
+ if (p == NULL) {
d.error = ERR_PACK(0, 0, r);
p = int_err_get_item(&d);
}
return 1;
case EVP_CTRL_AEAD_SET_TAG:
- if (!ptr) {
+ if (ptr == NULL) {
/* Tag len must be 0 to 16 */
if (arg < 0 || arg > 16)
return 0;
if (!EVP_PBE_find(EVP_PBE_TYPE_OUTER, OBJ_obj2nid(pbe_obj),
&cipher_nid, &md_nid, &keygen)) {
char obj_tmp[80];
+
EVPerr(EVP_F_EVP_PBE_CIPHERINIT, EVP_R_UNKNOWN_PBE_ALGORITHM);
- if (!pbe_obj)
+ if (pbe_obj == NULL)
OPENSSL_strlcpy(obj_tmp, "NULL", sizeof(obj_tmp));
else
i2t_ASN1_OBJECT(obj_tmp, sizeof(obj_tmp), pbe_obj);
return 0;
}
- if (!pass)
+ if (pass == NULL)
passlen = 0;
else if (passlen == -1)
passlen = strlen(pass);
return 0;
}
- if (!pbe->iter)
+ if (pbe->iter == NULL)
iter = 1;
else
iter = ASN1_INTEGER_get(pbe->iter);
salt = pbe->salt->data;
saltlen = pbe->salt->length;
- if (!pass)
+ if (pass == NULL)
passlen = 0;
else if (passlen == -1)
passlen = strlen(pass);
{
if (pkey == NULL)
return 0;
- if (!pkey->ameth || !pkey->ameth->pkey_security_bits)
+ if (pkey->ameth == NULL || pkey->ameth->pkey_security_bits == NULL)
return -2;
return pkey->ameth->pkey_security_bits(pkey);
}
return 0;
}
- if (!priv)
+ if (priv == NULL)
return 1;
if (EVP_PKEY_id(priv) != EVP_PKEY_RSA) {
pmeth_fn *ret;
EVP_PKEY_METHOD tmp;
const EVP_PKEY_METHOD *t = &tmp;
+
tmp.pkey_id = type;
if (app_pkey_methods) {
int idx;
ret = OBJ_bsearch_pmeth_func(&t, standard_methods,
sizeof(standard_methods) /
sizeof(pmeth_fn));
- if (!ret || !*ret)
+ if (ret == NULL || *ret == NULL)
return NULL;
return (**ret)();
}
{
static const char http_hdr[] = "%s %s HTTP/1.0\r\n";
- if (!path)
+ if (path == NULL)
path = "/";
if (BIO_printf(rctx->mem, http_hdr, op, path) <= 0)
for (p = line; *p && !ossl_isspace(*p); p++)
continue;
- if (!*p) {
+ if (*p == '\0') {
OCSPerr(OCSP_F_PARSE_HTTP_LINE1, OCSP_R_SERVER_RESPONSE_PARSE_ERROR);
return 0;
}
while (*p && ossl_isspace(*p))
p++;
- if (!*p) {
+ if (*p == '\0') {
OCSPerr(OCSP_F_PARSE_HTTP_LINE1, OCSP_R_SERVER_RESPONSE_PARSE_ERROR);
return 0;
}
for (q = p; *q && !ossl_isspace(*q); q++)
continue;
- if (!*q) {
+ if (*q == '\0') {
OCSPerr(OCSP_F_PARSE_HTTP_LINE1, OCSP_R_SERVER_RESPONSE_PARSE_ERROR);
return 0;
}
}
if (retcode != 200) {
OCSPerr(OCSP_F_PARSE_HTTP_LINE1, OCSP_R_SERVER_RESPONSE_ERROR);
- if (!*q)
+ if (*q == '\0')
ERR_add_error_data(2, "Code=", p);
else
ERR_add_error_data(4, "Code=", p, ",Reason=", q);
/* Check for initial colon */
p = strchr(buf, ':');
-
- if (!p)
+ if (p == NULL)
goto parse_err;
*(p++) = '\0';
host = p;
/* Check for trailing part of path */
-
p = strchr(p, '/');
-
- if (!p)
+ if (p == NULL)
*ppath = OPENSSL_strdup("/");
else {
*ppath = OPENSSL_strdup(p);
*p = '\0';
}
- if (!*ppath)
+ if (*ppath == NULL)
goto mem_err;
p = host;
/* ipv6 literal */
host++;
p = strchr(host, ']');
- if (!p)
+ if (p == NULL)
goto parse_err;
*p = '\0';
p++;
}
*pport = OPENSSL_strdup(port);
- if (!*pport)
+ if (*pport == NULL)
goto mem_err;
*phost = OPENSSL_strdup(host);
- if (!*phost)
+ if (*phost == NULL)
goto mem_err;
OPENSSL_free(buf);
int klen;
EVP_PKEY *ret;
char psbuf[PEM_BUFSIZE];
+
p8 = d2i_PKCS8_bio(bp, NULL);
- if (!p8)
+ if (p8 == NULL)
return NULL;
- if (cb)
+ if (cb != NULL)
klen = cb(psbuf, PEM_BUFSIZE, 0, u);
else
klen = PEM_def_callback(psbuf, PEM_BUFSIZE, 0, u);
p8inf = PKCS8_decrypt(p8, psbuf, klen);
X509_SIG_free(p8);
OPENSSL_cleanse(psbuf, klen);
- if (!p8inf)
+ if (p8inf == NULL)
return NULL;
ret = EVP_PKCS82PKEY(p8inf);
PKCS8_PRIV_KEY_INFO_free(p8inf);
if (!ret)
return NULL;
- if (x) {
+ if (x != NULL) {
EVP_PKEY_free(*x);
*x = ret;
}
if (strcmp(nm, PEM_STRING_PKCS8INF) == 0) {
PKCS8_PRIV_KEY_INFO *p8inf;
p8inf = d2i_PKCS8_PRIV_KEY_INFO(NULL, &p, len);
- if (!p8inf)
+ if (p8inf == NULL)
goto p8err;
ret = EVP_PKCS82PKEY(p8inf);
- if (x) {
+ if (x != NULL) {
EVP_PKEY_free((EVP_PKEY *)*x);
*x = ret;
}
int klen;
char psbuf[PEM_BUFSIZE];
p8 = d2i_X509_SIG(NULL, &p, len);
- if (!p8)
+ if (p8 == NULL)
goto p8err;
if (cb)
klen = cb(psbuf, PEM_BUFSIZE, 0, u);
p8inf = PKCS8_decrypt(p8, psbuf, klen);
X509_SIG_free(p8);
OPENSSL_cleanse(psbuf, klen);
- if (!p8inf)
+ if (p8inf == NULL)
goto p8err;
ret = EVP_PKCS82PKEY(p8inf);
if (x) {
{
const unsigned char *p = *in;
unsigned int pvk_magic, is_encrypted;
+
if (skip_magic) {
if (length < 20) {
PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_PVK_TOO_SHORT);
if (*pkeylen > PVK_MAX_KEYLEN || *psaltlen > PVK_MAX_SALTLEN)
return 0;
- if (is_encrypted && !*psaltlen) {
+ if (is_encrypted && *psaltlen == 0) {
PEMerr(PEM_F_DO_PVK_HEADER, PEM_R_INCONSISTENT_HEADER);
return 0;
}
else
pbe = PKCS5_pbe_set(pbe_nid, iter, salt, saltlen);
- if (!pbe) {
+ if (pbe == NULL) {
PKCS12err(PKCS12_F_PKCS12_PACK_P7ENCDATA, ERR_R_MALLOC_FAILURE);
goto err;
}
return 0;
}
- if (!pbe->iter)
+ if (pbe->iter == NULL)
iter = 1;
else
iter = ASN1_INTEGER_get(pbe->iter);
if (!mac_iter)
mac_iter = 1;
- if (!pkey && !cert && !ca) {
+ if (pkey == NULL && cert == NULL && ca == NULL) {
PKCS12err(PKCS12_F_PKCS12_CREATE, PKCS12_R_INVALID_NULL_ARGUMENT);
return NULL;
}
p12 = PKCS12_add_safes(safes, 0);
- if (!p12)
+ if (p12 == NULL)
goto err;
sk_PKCS7_pop_free(safes, PKCS7_free);
PKCS7 *p7 = NULL;
int free_safes = 0;
- if (!*psafes) {
+ if (*psafes == NULL) {
*psafes = sk_PKCS7_new_null();
- if (!*psafes)
+ if (*psafes == NULL)
return 0;
free_safes = 1;
- } else
- free_safes = 0;
+ }
if (nid_safe == 0)
#ifdef OPENSSL_NO_RC2
p7 = PKCS12_pack_p7data(bags);
else
p7 = PKCS12_pack_p7encdata(nid_safe, pass, -1, NULL, 0, iter, bags);
- if (!p7)
+ if (p7 == NULL)
goto err;
if (!sk_PKCS7_push(*psafes, p7))
static int pkcs12_add_bag(STACK_OF(PKCS12_SAFEBAG) **pbags,
PKCS12_SAFEBAG *bag)
{
- int free_bags;
- if (!pbags)
+ int free_bags = 0;
+
+ if (pbags == NULL)
return 1;
- if (!*pbags) {
+ if (*pbags == NULL) {
*pbags = sk_PKCS12_SAFEBAG_new_null();
- if (!*pbags)
+ if (*pbags == NULL)
return 0;
free_bags = 1;
- } else
- free_bags = 0;
+ }
if (!sk_PKCS12_SAFEBAG_push(*pbags, bag)) {
if (free_bags) {
PKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int nid_p7)
{
PKCS12 *p12;
+
if (nid_p7 <= 0)
nid_p7 = NID_pkcs7_data;
p12 = PKCS12_init(nid_p7);
-
- if (!p12)
+ if (p12 == NULL)
return NULL;
if (!PKCS12_pack_authsafes(p12, safes)) {
unsigned char *unipass;
int uniplen;
- if (!pass) {
+ if (pass == NULL) {
unipass = NULL;
uniplen = 0;
} else if (!OPENSSL_asc2uni(pass, passlen, &unipass, &uniplen)) {
unsigned char *unipass;
int uniplen;
- if (!pass) {
+ if (pass == NULL) {
unipass = NULL;
uniplen = 0;
} else if (!OPENSSL_utf82uni(pass, passlen, &unipass, &uniplen)) {
/* Check for NULL PKCS12 structure */
- if (!p12) {
+ if (p12 == NULL) {
PKCS12err(PKCS12_F_PKCS12_PARSE,
PKCS12_R_INVALID_NULL_PKCS12_POINTER);
return 0;
* password are two different things...
*/
- if (!pass || !*pass) {
+ if (pass == NULL || *pass == '\0') {
if (PKCS12_verify_mac(p12, NULL, 0))
pass = NULL;
else if (PKCS12_verify_mac(p12, "", 0))
}
while ((x = sk_X509_pop(ocerts))) {
- if (pkey && *pkey && cert && !*cert) {
+ if (pkey != NULL && *pkey != NULL
+ && cert != NULL && *cert == NULL) {
ERR_set_mark();
if (X509_check_private_key(x, *pkey)) {
*cert = x;
}
if (ca && x) {
- if (!*ca)
+ if (*ca == NULL)
*ca = sk_X509_new_null();
- if (!*ca)
+ if (*ca == NULL)
goto err;
if (!sk_X509_push(*ca, x))
goto err;
switch (PKCS12_SAFEBAG_get_nid(bag)) {
case NID_keyBag:
- if (!pkey || *pkey)
+ if (pkey == NULL || *pkey != NULL)
return 1;
*pkey = EVP_PKCS82PKEY(PKCS12_SAFEBAG_get0_p8inf(bag));
if (*pkey == NULL)
break;
case NID_pkcs8ShroudedKeyBag:
- if (!pkey || *pkey)
+ if (pkey == NULL || *pkey != NULL)
return 1;
if ((p8 = PKCS12_decrypt_skey(bag, pass, passlen)) == NULL)
return 0;
salt = p12->mac->salt->data;
saltlen = p12->mac->salt->length;
- if (!p12->mac->iter)
+ if (p12->mac->iter == NULL)
iter = 1;
else
iter = ASN1_INTEGER_get(p12->mac->iter);
{
/* Check for NULL PKCS12 structure */
- if (!p12) {
+ if (p12 == NULL) {
PKCS12err(PKCS12_F_PKCS12_NEWPASS,
PKCS12_R_INVALID_NULL_PKCS12_POINTER);
return 0;
else
p7new = PKCS12_pack_p7encdata(pbe_nid, newpass, -1, NULL,
pbe_saltlen, pbe_iter, bags);
- if (!p7new || !sk_PKCS7_push(newsafes, p7new))
+ if (p7new == NULL || !sk_PKCS7_push(newsafes, p7new))
goto err;
sk_PKCS12_SAFEBAG_pop_free(bags, PKCS12_SAFEBAG_free);
bags = NULL;
int *psaltlen)
{
PBEPARAM *pbe;
+
pbe = ASN1_TYPE_unpack_sequence(ASN1_ITEM_rptr(PBEPARAM), alg->parameter);
- if (!pbe)
+ if (pbe == NULL)
return 0;
*pnid = OBJ_obj2nid(alg->algorithm);
*piter = ASN1_INTEGER_get(pbe->iter);
ERR_clear_error();
pbe = PKCS5_pbe_set(pbe_nid, iter, salt, saltlen);
}
- if (!pbe) {
+ if (pbe == NULL) {
PKCS12err(PKCS12_F_PKCS8_ENCRYPT, ERR_R_ASN1_LIB);
return NULL;
}
size_t eklen;
pkey = X509_get0_pubkey(ri->cert);
-
- if (!pkey)
+ if (pkey == NULL)
return 0;
pctx = EVP_PKEY_CTX_new(pkey, NULL);
- if (!pctx)
+ if (pctx == NULL)
return 0;
if (EVP_PKEY_encrypt_init(pctx) <= 0)
EVP_PKEY_CTX *pctx = NULL;
unsigned char *ek = NULL;
size_t eklen;
-
int ret = -1;
pctx = EVP_PKEY_CTX_new(pkey, NULL);
- if (!pctx)
+ if (pctx == NULL)
return -1;
if (EVP_PKEY_decrypt_init(pctx) <= 0)
os = si->enc_digest;
pkey = X509_get0_pubkey(x509);
- if (!pkey) {
+ if (pkey == NULL) {
ret = -1;
goto err;
}
break;
case PKCS7_OP_GET_DETACHED_SIGNATURE:
if (nid == NID_pkcs7_signed) {
- if (!p7->d.sign || !p7->d.sign->contents->d.ptr)
+ if (p7->d.sign == NULL || p7->d.sign->contents->d.ptr == NULL)
ret = 1;
else
ret = 0;
BIO *p7bio = NULL;
BIO *tmpin = NULL, *tmpout = NULL;
- if (!p7) {
+ if (p7 == NULL) {
PKCS7err(PKCS7_F_PKCS7_VERIFY, PKCS7_R_INVALID_NULL_POINTER);
return 0;
}
X509 *signer;
int i;
- if (!p7) {
+ if (p7 == NULL) {
PKCS7err(PKCS7_F_PKCS7_GET0_SIGNERS, PKCS7_R_INVALID_NULL_POINTER);
return NULL;
}
int ret = 0, i;
char *buf = NULL;
- if (!p7) {
+ if (p7 == NULL) {
PKCS7err(PKCS7_F_PKCS7_DECRYPT, PKCS7_R_INVALID_NULL_POINTER);
return 0;
}
{
int ret = 0;
ASN1_OBJECT *policy_obj = NULL;
- if (!policy)
+
+ if (policy == NULL)
policy = NCONF_get_string(conf, section, ENV_DEFAULT_POLICY);
- if (!policy) {
+ if (policy == NULL) {
ts_CONF_lookup_fail(section, ENV_DEFAULT_POLICY);
goto err;
}
if (!OBJ_cmp(requested, current))
policy = current;
}
- if (!policy) {
+ if (policy == NULL) {
TSerr(TS_F_TS_RESP_GET_POLICY, TS_R_UNACCEPTABLE_POLICY);
TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION,
"Requested policy is not " "supported.");
size_t len;
const char *s, *ss, *p;
- if (dir == NULL || !*dir) {
+ if (dir == NULL || *dir == '\0') {
X509err(X509_F_ADD_CERT_DIR, X509_R_INVALID_DIRECTORY);
return 0;
}
continue;
} else if (*pstr == '@') {
STACK_OF(CONF_VALUE) *polsect;
+
polsect = X509V3_get_section(ctx, pstr + 1);
- if (!polsect) {
+ if (polsect == NULL) {
X509V3err(X509V3_F_R2I_CERTPOL, X509V3_R_INVALID_SECTION);
X509V3_conf_err(cnf);
X509V3_section_free(ctx, unot);
if (!qual)
goto err;
- if (!pol->qualifiers)
+ if (pol->qualifiers == NULL)
pol->qualifiers = sk_POLICYQUALINFO_new_null();
if (!sk_POLICYQUALINFO_push(pol->qualifiers, qual))
goto merr;
goto err;
}
}
- if (!pol->policyid) {
+ if (pol->policyid == NULL) {
X509V3err(X509V3_F_POLICY_SECTION, X509V3_R_NO_POLICY_IDENTIFIER);
goto err;
}
break;
}
}
- if (!pbn->lname)
+ if (pbn->lname == NULL)
goto err;
}
ret = 1;
goto err;
} else if (strcmp(cnf->name, "CRLissuer") == 0) {
point->CRLissuer = gnames_from_sectname(ctx, cnf->value);
- if (!point->CRLissuer)
+ if (point->CRLissuer == NULL)
goto err;
}
}
goto err;
point = crldp_from_section(ctx, dpsect);
X509V3_section_free(ctx, dpsect);
- if (!point)
+ if (point == NULL)
goto err;
sk_DIST_POINT_push(crld, point); /* no failure as it was reserved */
} else {
}
sk_ACCESS_DESCRIPTION_push(ainfo, acc); /* Cannot fail due to reserve */
ptmp = strchr(cnf->name, ';');
- if (!ptmp) {
+ if (ptmp == NULL) {
X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,
X509V3_R_INVALID_SYNTAX);
goto err;
{
char *baseptr = (char *)base->data;
char *dnsptr = (char *)dns->data;
+
/* Empty matches everything */
- if (!*baseptr)
+ if (*baseptr == '\0')
return X509_V_OK;
/*
* Otherwise can add zero or more components on the left so compare RHS
const char *hostptr = (char *)uri->data;
const char *p = strchr(hostptr, ':');
int hostlen;
+
/* Check for foo:// and skip past it */
- if (!p || (p[1] != '/') || (p[2] != '/'))
+ if (p == NULL || p[1] != '/' || p[2] != '/')
return X509_V_ERR_UNSUPPORTED_NAME_SYNTAX;
hostptr = p + 3;
p = strchr(hostptr, ':');
/* Otherwise look for trailing slash */
- if (!p)
+ if (p == NULL)
p = strchr(hostptr, '/');
- if (!p)
+ if (p == NULL)
hostlen = strlen(hostptr);
else
hostlen = p - hostptr;
} else if (strcmp(val->name, "policy") == 0) {
unsigned char *tmp_data = NULL;
long val_len;
- if (!*policy) {
+
+ if (*policy == NULL) {
*policy = ASN1_OCTET_STRING_new();
if (*policy == NULL) {
X509V3err(X509V3_F_PROCESS_PCI_VALUE, ERR_R_MALLOC_FAILURE);
goto err;
}
}
- if (!pcons->inhibitPolicyMapping && !pcons->requireExplicitPolicy) {
+ if (pcons->inhibitPolicyMapping == NULL
+ && pcons->requireExplicitPolicy == NULL) {
X509V3err(X509V3_F_V2I_POLICY_CONSTRAINTS,
X509V3_R_ILLEGAL_EMPTY_EXTENSION);
goto err;
/* dup supplied name */
ptmp->name = OPENSSL_strdup(name);
ptmp->sname = OPENSSL_strdup(sname);
- if (!ptmp->name || !ptmp->sname) {
+ if (ptmp->name == NULL|| ptmp->sname == NULL) {
X509V3err(X509V3_F_X509_PURPOSE_ADD, ERR_R_MALLOC_FAILURE);
goto err;
}
static void xptable_free(X509_PURPOSE *p)
{
- if (!p)
+ if (p == NULL)
return;
if (p->flags & X509_PURPOSE_DYNAMIC) {
if (p->flags & X509_PURPOSE_DYNAMIC_NAME) {
{
SXNET *sx = NULL;
SXNETID *id = NULL;
- if (!psx || !zone || !user) {
+
+ if (psx == NULL || zone == NULL || user == NULL) {
X509V3err(X509V3_F_SXNET_ADD_ID_INTEGER,
X509V3_R_INVALID_NULL_ARGUMENT);
return 0;
p = name;
while (*p && ossl_isspace(*p))
p++;
- if (!*p)
+ if (*p == '\0')
return NULL;
q = p + strlen(p) - 1;
while ((q != p) && ossl_isspace(*q))
q--;
if (p != q)
q[1] = 0;
- if (!*p)
+ if (*p == '\0')
return NULL;
return p;
}
unsigned char ipout[32];
char *iptmp = NULL, *p;
int iplen1, iplen2;
+
p = strchr(ipasc, '/');
- if (!p)
+ if (p == NULL)
return NULL;
iptmp = OPENSSL_strdup(ipasc);
- if (!iptmp)
+ if (iptmp == NULL)
return NULL;
p = iptmp + (p - ipasc);
*p++ = 0;
static void trtable_free(X509_TRUST *p)
{
- if (!p)
+ if (p == NULL)
return;
if (p->flags & X509_TRUST_DYNAMIC) {
if (p->flags & X509_TRUST_DYNAMIC_NAME)
{
int idx;
/* If purpose not set use default */
- if (!purpose)
+ if (purpose == 0)
purpose = def_purpose;
/* If we have a purpose then check it is valid */
- if (purpose) {
+ if (purpose != 0) {
X509_PURPOSE *ptmp;
idx = X509_PURPOSE_get_by_id(purpose);
if (idx == -1) {
int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name)
{
const X509_VERIFY_PARAM *param;
+
param = X509_VERIFY_PARAM_lookup(name);
- if (!param)
+ if (param == NULL)
return 0;
return X509_VERIFY_PARAM_inherit(ctx->param, param);
}
int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param,
ASN1_OBJECT *policy)
{
- if (!param->policies) {
+ if (param->policies == NULL) {
param->policies = sk_ASN1_OBJECT_new_null();
- if (!param->policies)
+ if (param->policies == NULL)
return 0;
}
if (!sk_ASN1_OBJECT_push(param->policies, policy))
int i;
ASN1_OBJECT *oid, *doid;
- if (!param)
+ if (param == NULL)
return 0;
sk_ASN1_OBJECT_pop_free(param->policies, ASN1_OBJECT_free);
- if (!policies) {
+ if (policies == NULL) {
param->policies = NULL;
return 1;
}
param->policies = sk_ASN1_OBJECT_new_null();
- if (!param->policies)
+ if (param->policies == NULL)
return 0;
for (i = 0; i < sk_ASN1_OBJECT_num(policies); i++) {
{
PKCS8_PRIV_KEY_INFO *p8inf;
int ret;
+
p8inf = EVP_PKEY2PKCS8(key);
- if (!p8inf)
+ if (p8inf == NULL)
return 0;
ret = i2d_PKCS8_PRIV_KEY_INFO_fp(fp, p8inf);
PKCS8_PRIV_KEY_INFO_free(p8inf);
{
PKCS8_PRIV_KEY_INFO *p8inf;
int ret;
+
p8inf = EVP_PKEY2PKCS8(key);
- if (!p8inf)
+ if (p8inf == NULL)
return 0;
ret = i2d_PKCS8_PRIV_KEY_INFO_bio(bp, p8inf);
PKCS8_PRIV_KEY_INFO_free(p8inf);
{
X509_NAME *a;
- if (!pval || !*pval)
+ if (pval == NULL || *pval == NULL)
return;
a = (X509_NAME *)*pval;
l = 80 - 2 - obase;
b = X509_NAME_oneline(name, NULL, 0);
- if (!b)
+ if (b == NULL)
return 0;
- if (!*b) {
+ if (*b == '\0') {
OPENSSL_free(b);
return 1;
}
X509_PUBKEY *xpk;
EVP_PKEY *pktmp;
const unsigned char *q;
+
q = *pp;
xpk = d2i_X509_PUBKEY(NULL, &q, length);
- if (!xpk)
+ if (xpk == NULL)
return NULL;
pktmp = X509_PUBKEY_get(xpk);
X509_PUBKEY_free(xpk);
- if (!pktmp)
+ if (pktmp == NULL)
return NULL;
*pp = q;
- if (a) {
+ if (a != NULL) {
EVP_PKEY_free(*a);
*a = pktmp;
}
EVP_PKEY *pkey;
RSA *key;
const unsigned char *q;
+
q = *pp;
pkey = d2i_PUBKEY(NULL, &q, length);
- if (!pkey)
+ if (pkey == NULL)
return NULL;
key = EVP_PKEY_get1_RSA(pkey);
EVP_PKEY_free(pkey);
- if (!key)
+ if (key == NULL)
return NULL;
*pp = q;
- if (a) {
+ if (a != NULL) {
RSA_free(*a);
*a = key;
}
EVP_PKEY *pkey;
DSA *key;
const unsigned char *q;
+
q = *pp;
pkey = d2i_PUBKEY(NULL, &q, length);
- if (!pkey)
+ if (pkey == NULL)
return NULL;
key = EVP_PKEY_get1_DSA(pkey);
EVP_PKEY_free(pkey);
- if (!key)
+ if (key == NULL)
return NULL;
*pp = q;
- if (a) {
+ if (a != NULL) {
DSA_free(*a);
*a = key;
}
EVP_PKEY *pkey;
EC_KEY *key;
const unsigned char *q;
+
q = *pp;
pkey = d2i_PUBKEY(NULL, &q, length);
- if (!pkey)
+ if (pkey == NULL)
return NULL;
key = EVP_PKEY_get1_EC_KEY(pkey);
EVP_PKEY_free(pkey);
- if (!key)
+ if (key == NULL)
return NULL;
*pp = q;
- if (a) {
+ if (a != NULL) {
EC_KEY_free(*a);
*a = key;
}
{
EVP_PKEY *pktmp;
int ret;
- if (!a)
+
+ if (a == NULL)
return 0;
if ((pktmp = EVP_PKEY_new()) == NULL) {
ASN1err(ASN1_F_I2D_EC_PUBKEY, ERR_R_MALLOC_FAILURE);
CRYPT_KEY_PROV_INFO *pinfo)
{
char *provname = NULL, *contname = NULL;
- if (!pinfo) {
+
+ if (pinfo == NULL) {
BIO_printf(out, " No Private Key\n");
return;
}
provname = wide_to_asc(pinfo->pwszProvName);
contname = wide_to_asc(pinfo->pwszContainerName);
- if (!provname || !contname)
+ if (provname == NULL || contname == NULL)
goto err;
BIO_printf(out, " Private Key Info:\n");
sk_X509_free(certs);
- if (!*pcert)
+ if (*pcert == NULL)
return 0;
/* Setup key for selected certificate */
if (as == NULL)
goto err;
- if (!a || !*a) {
+ if (a == NULL || *a == NULL) {
ret = SSL_SESSION_new();
if (ret == NULL)
goto err;
char **pfilename = &cctx->cert_filename[c->key - c->pkeys];
OPENSSL_free(*pfilename);
*pfilename = OPENSSL_strdup(value);
- if (!*pfilename)
+ if (*pfilename == NULL)
rv = 0;
}
static int ssl_conf_cmd_skip_prefix(SSL_CONF_CTX *cctx, const char **pcmd)
{
- if (!pcmd || !*pcmd)
+ if (pcmd == NULL || *pcmd == NULL)
return 0;
/* If a prefix is set, check and skip */
if (cctx->prefix) {
{
int rv;
const char *arg = NULL, *argn;
- if (pargc && *pargc == 0)
+
+ if (pargc != NULL && *pargc == 0)
return 0;
- if (!pargc || *pargc > 0)
+ if (pargc == NULL || *pargc > 0)
arg = **pargv;
if (arg == NULL)
return 0;
- if (!pargc || *pargc > 1)
+ if (pargc == NULL || *pargc > 1)
argn = (*pargv)[1];
else
argn = NULL;
unsigned *len)
{
*data = s->ext.npn;
- if (!*data) {
+ if (*data == NULL) {
*len = 0;
} else {
*len = (unsigned int)s->ext.npn_len;
* Get server certificate PKEY and create ctx from it
*/
peer_cert = s->session->peer;
- if (!peer_cert) {
+ if (peer_cert == NULL) {
SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_TLS_CONSTRUCT_CKE_GOST,
SSL_R_NO_GOST_CERTIFICATE_SENT_BY_PEER);
return 0;
* to read gives us somewhat better guarantees that all data sent is in fact
* received.
*/
- if (!peer->bytes_to_write && !peer->bytes_to_read) {
+ if (peer->bytes_to_write == 0 && peer->bytes_to_read == 0) {
peer->status = PEER_SUCCESS;
}
}
/* Skip over leading spaces */
while (*p && isspace((unsigned char)*p))
p++;
- if (!*p)
+ if (*p == '\0')
return NULL;
for (q = p + strlen(p) - 1; q != p && isspace((unsigned char)*q); )