diff options
Diffstat (limited to 'crypto/cms')
-rw-r--r-- | crypto/cms/cms_cd.c | 4 | ||||
-rw-r--r-- | crypto/cms/cms_dd.c | 4 | ||||
-rw-r--r-- | crypto/cms/cms_enc.c | 8 | ||||
-rw-r--r-- | crypto/cms/cms_env.c | 14 | ||||
-rw-r--r-- | crypto/cms/cms_ess.c | 2 | ||||
-rw-r--r-- | crypto/cms/cms_io.c | 6 | ||||
-rw-r--r-- | crypto/cms/cms_kari.c | 2 | ||||
-rw-r--r-- | crypto/cms/cms_lib.c | 8 | ||||
-rw-r--r-- | crypto/cms/cms_pwri.c | 17 | ||||
-rw-r--r-- | crypto/cms/cms_sd.c | 20 | ||||
-rw-r--r-- | crypto/cms/cms_smime.c | 6 |
11 files changed, 48 insertions, 43 deletions
diff --git a/crypto/cms/cms_cd.c b/crypto/cms/cms_cd.c index 81cc6c51d5..1b84309efb 100644 --- a/crypto/cms/cms_cd.c +++ b/crypto/cms/cms_cd.c @@ -82,12 +82,12 @@ CMS_ContentInfo *cms_CompressedData_create(int comp_nid) return NULL; } cms = CMS_ContentInfo_new(); - if (!cms) + if (cms == NULL) return NULL; cd = M_ASN1_new_of(CMS_CompressedData); - if (!cd) + if (cd == NULL) goto err; cms->contentType = OBJ_nid2obj(NID_id_smime_ct_compressedData); diff --git a/crypto/cms/cms_dd.c b/crypto/cms/cms_dd.c index 7609b6f8d4..426f8cd74c 100644 --- a/crypto/cms/cms_dd.c +++ b/crypto/cms/cms_dd.c @@ -67,12 +67,12 @@ CMS_ContentInfo *cms_DigestedData_create(const EVP_MD *md) CMS_ContentInfo *cms; CMS_DigestedData *dd; cms = CMS_ContentInfo_new(); - if (!cms) + if (cms == NULL) return NULL; dd = M_ASN1_new_of(CMS_DigestedData); - if (!dd) + if (dd == NULL) goto err; cms->contentType = OBJ_nid2obj(NID_pkcs7_digest); diff --git a/crypto/cms/cms_enc.c b/crypto/cms/cms_enc.c index fc66f60060..a16120fc72 100644 --- a/crypto/cms/cms_enc.c +++ b/crypto/cms/cms_enc.c @@ -82,7 +82,7 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec) enc = ec->cipher ? 1 : 0; b = BIO_new(BIO_f_cipher()); - if (!b) { + if (b == NULL) { CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO, ERR_R_MALLOC_FAILURE); return NULL; } @@ -130,7 +130,7 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec) /* Generate random session key */ if (!enc || !ec->key) { tkey = OPENSSL_malloc(tkeylen); - if (!tkey) { + if (tkey == NULL) { CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO, ERR_R_MALLOC_FAILURE); goto err; } @@ -179,7 +179,7 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec) if (piv) { calg->parameter = ASN1_TYPE_new(); - if (!calg->parameter) { + if (calg->parameter == NULL) { CMSerr(CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO, ERR_R_MALLOC_FAILURE); goto err; } @@ -210,7 +210,7 @@ int cms_EncryptedContent_init(CMS_EncryptedContentInfo *ec, ec->cipher = cipher; if (key) { ec->key = OPENSSL_malloc(keylen); - if (!ec->key) + if (ec->key == NULL) return 0; memcpy(ec->key, key, keylen); } diff --git a/crypto/cms/cms_env.c b/crypto/cms/cms_env.c index e133bcc6a7..b9775e0ad2 100644 --- a/crypto/cms/cms_env.c +++ b/crypto/cms/cms_env.c @@ -153,10 +153,10 @@ CMS_ContentInfo *CMS_EnvelopedData_create(const EVP_CIPHER *cipher) CMS_ContentInfo *cms; CMS_EnvelopedData *env; cms = CMS_ContentInfo_new(); - if (!cms) + if (cms == NULL) goto merr; env = cms_enveloped_data_init(cms); - if (!env) + if (env == NULL) goto merr; if (!cms_EncryptedContent_init(env->encryptedContentInfo, cipher, NULL, 0)) @@ -208,7 +208,7 @@ static int cms_RecipientInfo_ktri_init(CMS_RecipientInfo *ri, X509 *recip, if (flags & CMS_KEY_PARAM) { ktri->pctx = EVP_PKEY_CTX_new(ktri->pkey, NULL); - if (!ktri->pctx) + if (ktri->pctx == NULL) return 0; if (EVP_PKEY_encrypt_init(ktri->pctx) <= 0) return 0; @@ -362,7 +362,7 @@ static int cms_RecipientInfo_ktri_encrypt(CMS_ContentInfo *cms, goto err; } else { pctx = EVP_PKEY_CTX_new(ktri->pkey, NULL); - if (!pctx) + if (pctx == NULL) return 0; if (EVP_PKEY_encrypt_init(pctx) <= 0) @@ -420,7 +420,7 @@ static int cms_RecipientInfo_ktri_decrypt(CMS_ContentInfo *cms, } ktri->pctx = EVP_PKEY_CTX_new(pkey, NULL); - if (!ktri->pctx) + if (ktri->pctx == NULL) return 0; if (EVP_PKEY_decrypt_init(ktri->pctx) <= 0) @@ -685,7 +685,7 @@ static int cms_RecipientInfo_kekri_encrypt(CMS_ContentInfo *cms, wkey = OPENSSL_malloc(ec->keylen + 8); - if (!wkey) { + if (wkey == NULL) { CMSerr(CMS_F_CMS_RECIPIENTINFO_KEKRI_ENCRYPT, ERR_R_MALLOC_FAILURE); goto err; } @@ -755,7 +755,7 @@ static int cms_RecipientInfo_kekri_decrypt(CMS_ContentInfo *cms, ukey = OPENSSL_malloc(kekri->encryptedKey->length - 8); - if (!ukey) { + if (ukey == NULL) { CMSerr(CMS_F_CMS_RECIPIENTINFO_KEKRI_DECRYPT, ERR_R_MALLOC_FAILURE); goto err; } diff --git a/crypto/cms/cms_ess.c b/crypto/cms/cms_ess.c index 2149749983..3e35d060d9 100644 --- a/crypto/cms/cms_ess.c +++ b/crypto/cms/cms_ess.c @@ -97,7 +97,7 @@ CMS_ReceiptRequest *CMS_ReceiptRequest_create0(unsigned char *id, int idlen, CMS_ReceiptRequest *rr = NULL; rr = CMS_ReceiptRequest_new(); - if (!rr) + if (rr == NULL) goto merr; if (id) ASN1_STRING_set0(rr->signedContentIdentifier, id, idlen); diff --git a/crypto/cms/cms_io.c b/crypto/cms/cms_io.c index 084a2cc15c..1d1d432153 100644 --- a/crypto/cms/cms_io.c +++ b/crypto/cms/cms_io.c @@ -63,11 +63,11 @@ int CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms) { ASN1_OCTET_STRING **pos; pos = CMS_get0_content(cms); - if (!pos) + if (pos == NULL) return 0; - if (!*pos) + if (*pos == NULL) *pos = ASN1_OCTET_STRING_new(); - if (*pos) { + if (*pos != NULL) { (*pos)->flags |= ASN1_STRING_FLAG_NDEF; (*pos)->flags &= ~ASN1_STRING_FLAG_CONT; *boundary = &(*pos)->data; diff --git a/crypto/cms/cms_kari.c b/crypto/cms/cms_kari.c index 77181bc775..c6d45a0c2a 100644 --- a/crypto/cms/cms_kari.c +++ b/crypto/cms/cms_kari.c @@ -252,7 +252,7 @@ static int cms_kek_cipher(unsigned char **pout, size_t *poutlen, if (!EVP_CipherUpdate(&kari->ctx, NULL, &outlen, in, inlen)) goto err; out = OPENSSL_malloc(outlen); - if (!out) + if (out == NULL) goto err; if (!EVP_CipherUpdate(&kari->ctx, out, &outlen, in, inlen)) goto err; diff --git a/crypto/cms/cms_lib.c b/crypto/cms/cms_lib.c index 157590d845..fdc69f6f8f 100644 --- a/crypto/cms/cms_lib.c +++ b/crypto/cms/cms_lib.c @@ -76,7 +76,7 @@ CMS_ContentInfo *cms_Data_create(void) { CMS_ContentInfo *cms; cms = CMS_ContentInfo_new(); - if (cms) { + if (cms != NULL) { cms->contentType = OBJ_nid2obj(NID_pkcs7_data); /* Never detached */ CMS_set_detached(cms, 0); @@ -316,9 +316,9 @@ int CMS_set_detached(CMS_ContentInfo *cms, int detached) *pos = NULL; return 1; } - if (!*pos) + if (*pos == NULL) *pos = ASN1_OCTET_STRING_new(); - if (*pos) { + if (*pos != NULL) { /* * NB: special flag to show content is created and not read in. */ @@ -344,7 +344,7 @@ BIO *cms_DigestAlgorithm_init_bio(X509_ALGOR *digestAlgorithm) goto err; } mdbio = BIO_new(BIO_f_md()); - if (!mdbio || !BIO_set_md(mdbio, digest)) { + if (mdbio == NULL || !BIO_set_md(mdbio, digest)) { CMSerr(CMS_F_CMS_DIGESTALGORITHM_INIT_BIO, CMS_R_MD_BIO_INIT_ERROR); goto err; } diff --git a/crypto/cms/cms_pwri.c b/crypto/cms/cms_pwri.c index f722d9a9b6..d662938768 100644 --- a/crypto/cms/cms_pwri.c +++ b/crypto/cms/cms_pwri.c @@ -121,6 +121,9 @@ CMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms, /* Setup algorithm identifier for cipher */ encalg = X509_ALGOR_new(); + if (encalg == NULL) { + goto merr; + } EVP_CIPHER_CTX_init(&ctx); if (EVP_EncryptInit_ex(&ctx, kekciph, NULL, NULL, NULL) <= 0) { @@ -155,11 +158,11 @@ CMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms, /* Initialize recipient info */ ri = M_ASN1_new_of(CMS_RecipientInfo); - if (!ri) + if (ri == NULL) goto merr; ri->d.pwri = M_ASN1_new_of(CMS_PasswordRecipientInfo); - if (!ri->d.pwri) + if (ri->d.pwri == NULL) goto merr; ri->type = CMS_RECIPINFO_PASS; @@ -167,11 +170,11 @@ CMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms, /* Since this is overwritten, free up empty structure already there */ X509_ALGOR_free(pwri->keyEncryptionAlgorithm); pwri->keyEncryptionAlgorithm = X509_ALGOR_new(); - if (!pwri->keyEncryptionAlgorithm) + if (pwri->keyEncryptionAlgorithm == NULL) goto merr; pwri->keyEncryptionAlgorithm->algorithm = OBJ_nid2obj(wrap_nid); pwri->keyEncryptionAlgorithm->parameter = ASN1_TYPE_new(); - if (!pwri->keyEncryptionAlgorithm->parameter) + if (pwri->keyEncryptionAlgorithm->parameter == NULL) goto merr; if (!ASN1_item_pack(encalg, ASN1_ITEM_rptr(X509_ALGOR), @@ -230,7 +233,7 @@ static int kek_unwrap_key(unsigned char *out, size_t *outlen, return 0; } tmp = OPENSSL_malloc(inlen); - if (!tmp) + if (tmp == NULL) return 0; /* setup IV by decrypting last two blocks */ if (!EVP_DecryptUpdate(ctx, tmp + inlen - 2 * blocklen, &outl, @@ -388,7 +391,7 @@ int cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri, key = OPENSSL_malloc(keylen); - if (!key) + if (key == NULL) goto err; if (!kek_wrap_key(key, &keylen, ec->key, ec->keylen, &kekctx)) @@ -398,7 +401,7 @@ int cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri, } else { key = OPENSSL_malloc(pwri->encryptedKey->length); - if (!key) { + if (key == NULL) { CMSerr(CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT, ERR_R_MALLOC_FAILURE); goto err; } diff --git a/crypto/cms/cms_sd.c b/crypto/cms/cms_sd.c index 50064e286c..1720bcd870 100644 --- a/crypto/cms/cms_sd.c +++ b/crypto/cms/cms_sd.c @@ -332,7 +332,7 @@ CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms, if (i == sk_X509_ALGOR_num(sd->digestAlgorithms)) { alg = X509_ALGOR_new(); - if (!alg) + if (alg == NULL) goto merr; X509_ALGOR_set_md(alg, md); if (!sk_X509_ALGOR_push(sd->digestAlgorithms, alg)) { @@ -381,7 +381,7 @@ CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms, if (flags & CMS_KEY_PARAM) { if (flags & CMS_NOATTR) { si->pctx = EVP_PKEY_CTX_new(si->pkey, NULL); - if (!si->pctx) + if (si->pctx == NULL) goto err; if (EVP_PKEY_sign_init(si->pctx) <= 0) goto err; @@ -617,7 +617,7 @@ static int cms_SignerInfo_content_sign(CMS_ContentInfo *cms, goto err; siglen = EVP_PKEY_size(si->pkey); sig = OPENSSL_malloc(siglen); - if (!sig) { + if (sig == NULL) { CMSerr(CMS_F_CMS_SIGNERINFO_CONTENT_SIGN, ERR_R_MALLOC_FAILURE); goto err; } @@ -630,7 +630,7 @@ static int cms_SignerInfo_content_sign(CMS_ContentInfo *cms, unsigned char *sig; unsigned int siglen; sig = OPENSSL_malloc(EVP_PKEY_size(si->pkey)); - if (!sig) { + if (sig == NULL) { CMSerr(CMS_F_CMS_SIGNERINFO_CONTENT_SIGN, ERR_R_MALLOC_FAILURE); goto err; } @@ -708,7 +708,7 @@ int CMS_SignerInfo_sign(CMS_SignerInfo *si) goto err; OPENSSL_free(abuf); abuf = OPENSSL_malloc(siglen); - if (!abuf) + if (abuf == NULL) goto err; if (EVP_DigestSignFinal(mctx, abuf, &siglen) <= 0) goto err; @@ -851,6 +851,8 @@ int CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain) } else { const EVP_MD *md = EVP_MD_CTX_md(&mctx); pkctx = EVP_PKEY_CTX_new(si->pkey, NULL); + if (pkctx == NULL) + goto err; if (EVP_PKEY_verify_init(pkctx) <= 0) goto err; if (EVP_PKEY_CTX_set_signature_md(pkctx, md) <= 0) @@ -894,20 +896,20 @@ int CMS_add_simple_smimecap(STACK_OF(X509_ALGOR) **algs, ASN1_INTEGER *key = NULL; if (keysize > 0) { key = ASN1_INTEGER_new(); - if (!key || !ASN1_INTEGER_set(key, keysize)) + if (key == NULL || !ASN1_INTEGER_set(key, keysize)) return 0; } alg = X509_ALGOR_new(); - if (!alg) { + if (alg == NULL) { ASN1_INTEGER_free(key); return 0; } X509_ALGOR_set0(alg, OBJ_nid2obj(algnid), key ? V_ASN1_INTEGER : V_ASN1_UNDEF, key); - if (!*algs) + if (*algs == NULL) *algs = sk_X509_ALGOR_new_null(); - if (!*algs || !sk_X509_ALGOR_push(*algs, alg)) { + if (*algs == NULL || !sk_X509_ALGOR_push(*algs, alg)) { X509_ALGOR_free(alg); return 0; } diff --git a/crypto/cms/cms_smime.c b/crypto/cms/cms_smime.c index 6bed211384..5b55f055f7 100644 --- a/crypto/cms/cms_smime.c +++ b/crypto/cms/cms_smime.c @@ -82,7 +82,7 @@ static int cms_copy_content(BIO *out, BIO *in, unsigned int flags) tmpout = cms_get_text_bio(out, flags); - if (!tmpout) { + if (tmpout == NULL) { CMSerr(CMS_F_CMS_COPY_CONTENT, ERR_R_MALLOC_FAILURE); goto err; } @@ -253,7 +253,7 @@ CMS_ContentInfo *CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher, return NULL; } cms = CMS_ContentInfo_new(); - if (!cms) + if (cms == NULL) return NULL; if (!CMS_EncryptedData_set1_key(cms, cipher, key, keylen)) return NULL; @@ -482,7 +482,7 @@ CMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey, int i; cms = CMS_ContentInfo_new(); - if (!cms || !CMS_SignedData_init(cms)) + if (cms == NULL || !CMS_SignedData_init(cms)) goto merr; if (flags & CMS_ASCIICRLF && !CMS_set1_eContentType(cms, |