diff options
author | Rich Salz <rsalz@akamai.com> | 2019-09-16 21:28:57 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2019-10-09 21:32:15 +0200 |
commit | 12a765a5235f181c2f4992b615eb5f892c368e88 (patch) | |
tree | 67ece1a3fb210bd4895aea73649773fc912a60d6 /crypto/pem | |
parent | Refactor -passin/-passout documentation (diff) | |
download | openssl-12a765a5235f181c2f4992b615eb5f892c368e88.tar.xz openssl-12a765a5235f181c2f4992b615eb5f892c368e88.zip |
Explicitly test against NULL; do not use !p or similar
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)
Diffstat (limited to 'crypto/pem')
-rw-r--r-- | crypto/pem/pem_pk8.c | 9 | ||||
-rw-r--r-- | crypto/pem/pem_pkey.c | 8 | ||||
-rw-r--r-- | crypto/pem/pvkfmt.c | 3 |
3 files changed, 11 insertions, 9 deletions
diff --git a/crypto/pem/pem_pk8.c b/crypto/pem/pem_pk8.c index d8bb9bbf8f..642d4f6e24 100644 --- a/crypto/pem/pem_pk8.c +++ b/crypto/pem/pem_pk8.c @@ -117,10 +117,11 @@ EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, 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); @@ -132,13 +133,13 @@ EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, 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; } diff --git a/crypto/pem/pem_pkey.c b/crypto/pem/pem_pkey.c index 54596e4093..7132a7ad80 100644 --- a/crypto/pem/pem_pkey.c +++ b/crypto/pem/pem_pkey.c @@ -40,10 +40,10 @@ EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, 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; } @@ -54,7 +54,7 @@ EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, 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); @@ -68,7 +68,7 @@ EVP_PKEY *PEM_read_bio_PrivateKey(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, 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) { diff --git a/crypto/pem/pvkfmt.c b/crypto/pem/pvkfmt.c index adf2914433..6bcde93d6c 100644 --- a/crypto/pem/pvkfmt.c +++ b/crypto/pem/pvkfmt.c @@ -617,6 +617,7 @@ static int do_PVK_header(const unsigned char **in, unsigned int length, { 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); @@ -645,7 +646,7 @@ static int do_PVK_header(const unsigned char **in, unsigned int length, 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; } |