diff options
author | Matt Caswell <matt@openssl.org> | 2015-10-30 12:12:26 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2015-11-09 23:48:41 +0100 |
commit | 90945fa31a42dcf3beb90540c618e4d627c595ea (patch) | |
tree | e73870c253abf0c37ca618384e30a7937a996b55 /crypto/pem | |
parent | Standardise our style for checking malloc failures (diff) | |
download | openssl-90945fa31a42dcf3beb90540c618e4d627c595ea.tar.xz openssl-90945fa31a42dcf3beb90540c618e4d627c595ea.zip |
Continue standardising malloc style for libcrypto
Continuing from previous commit ensure our style is consistent for malloc
return checks.
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
Diffstat (limited to 'crypto/pem')
-rw-r--r-- | crypto/pem/pem_info.c | 6 | ||||
-rw-r--r-- | crypto/pem/pem_pkey.c | 2 | ||||
-rw-r--r-- | crypto/pem/pvkfmt.c | 18 |
3 files changed, 16 insertions, 10 deletions
diff --git a/crypto/pem/pem_info.c b/crypto/pem/pem_info.c index 045f568e0c..0cbd081b38 100644 --- a/crypto/pem/pem_info.c +++ b/crypto/pem/pem_info.c @@ -172,6 +172,8 @@ STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, xi->enc_len = 0; xi->x_pkey = X509_PKEY_new(); + if (xi->x_pkey == NULL) + goto err; ptype = EVP_PKEY_RSA; pp = &xi->x_pkey->dec_pkey; if ((int)strlen(header) > 10) /* assume encrypted */ @@ -193,6 +195,8 @@ STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, xi->enc_len = 0; xi->x_pkey = X509_PKEY_new(); + if (xi->x_pkey == NULL) + goto err; ptype = EVP_PKEY_DSA; pp = &xi->x_pkey->dec_pkey; if ((int)strlen(header) > 10) /* assume encrypted */ @@ -214,6 +218,8 @@ STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, xi->enc_len = 0; xi->x_pkey = X509_PKEY_new(); + if (xi->x_pkey == NULL) + goto err; ptype = EVP_PKEY_EC; pp = &xi->x_pkey->dec_pkey; if ((int)strlen(header) > 10) /* assume encrypted */ diff --git a/crypto/pem/pem_pkey.c b/crypto/pem/pem_pkey.c index 893675fc40..1a249f5588 100644 --- a/crypto/pem/pem_pkey.c +++ b/crypto/pem/pem_pkey.c @@ -173,7 +173,7 @@ EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x) if ((slen = pem_check_suffix(nm, "PARAMETERS")) > 0) { ret = EVP_PKEY_new(); - if (!ret) + if (ret == NULL) goto err; if (!EVP_PKEY_set_type_str(ret, nm, slen) || !ret->ameth->param_decode diff --git a/crypto/pem/pvkfmt.c b/crypto/pem/pvkfmt.c index 47fb9ac71d..50f19f3068 100644 --- a/crypto/pem/pvkfmt.c +++ b/crypto/pem/pvkfmt.c @@ -98,7 +98,7 @@ static int read_lebn(const unsigned char **in, unsigned int nbyte, BIGNUM **r) unsigned int i; p = *in + nbyte - 1; tmpbuf = OPENSSL_malloc(nbyte); - if (!tmpbuf) + if (tmpbuf == NULL) return 0; q = tmpbuf; for (i = 0; i < nbyte; i++) @@ -269,7 +269,7 @@ static EVP_PKEY *do_b2i_bio(BIO *in, int ispub) length = blob_length(bitlen, isdss, ispub); buf = OPENSSL_malloc(length); - if (!buf) { + if (buf == NULL) { PEMerr(PEM_F_DO_B2I_BIO, ERR_R_MALLOC_FAILURE); goto err; } @@ -301,7 +301,7 @@ static EVP_PKEY *b2i_dss(const unsigned char **in, unsigned int length, dsa = DSA_new(); ret = EVP_PKEY_new(); - if (!dsa || !ret) + if (dsa == NULL || ret == NULL) goto memerr; if (!read_lebn(&p, nbyte, &dsa->p)) goto memerr; @@ -350,10 +350,10 @@ static EVP_PKEY *b2i_rsa(const unsigned char **in, unsigned int length, hnbyte = (bitlen + 15) >> 4; rsa = RSA_new(); ret = EVP_PKEY_new(); - if (!rsa || !ret) + if (rsa == NULL || ret == NULL) goto memerr; rsa->e = BN_new(); - if (!rsa->e) + if (rsa->e == NULL) goto memerr; if (!BN_set_word(rsa->e, read_ledword(&p))) goto memerr; @@ -468,7 +468,7 @@ static int do_i2b(unsigned char **out, EVP_PKEY *pk, int ispub) p = *out; else { p = OPENSSL_malloc(outlen); - if (!p) + if (p == NULL) return -1; *out = p; noinc = 1; @@ -687,7 +687,7 @@ static EVP_PKEY *do_PVK_body(const unsigned char **in, goto err; } enctmp = OPENSSL_malloc(keylen + 8); - if (!enctmp) { + if (enctmp == NULL) { PEMerr(PEM_F_DO_PVK_BODY, ERR_R_MALLOC_FAILURE); goto err; } @@ -755,7 +755,7 @@ EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u) return 0; buflen = (int)keylen + saltlen; buf = OPENSSL_malloc(buflen); - if (!buf) { + if (buf == NULL) { PEMerr(PEM_F_B2I_PVK_BIO, ERR_R_MALLOC_FAILURE); return 0; } @@ -790,7 +790,7 @@ static int i2b_PVK(unsigned char **out, EVP_PKEY *pk, int enclevel, p = *out; else { p = OPENSSL_malloc(outlen); - if (!p) { + if (p == NULL) { PEMerr(PEM_F_I2B_PVK, ERR_R_MALLOC_FAILURE); return -1; } |