diff options
author | Pauli <pauli@openssl.org> | 2021-06-07 09:39:55 +1000 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2021-06-08 19:32:17 +1000 |
commit | 9428977994921d23b6aabc047298db3c55867709 (patch) | |
tree | 16e4f2c7beb5e2f70446c542a25c3733cde3d974 | |
parent | 0341ff9774283b85179bc07c0cfc80d6e547771e (diff) |
pkcs12: fix Coverity 1485667 logically dead code
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15635)
-rw-r--r-- | crypto/pkcs12/p12_mutl.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/crypto/pkcs12/p12_mutl.c b/crypto/pkcs12/p12_mutl.c index 88655651a0..afdb8d688b 100644 --- a/crypto/pkcs12/p12_mutl.c +++ b/crypto/pkcs12/p12_mutl.c @@ -249,23 +249,22 @@ int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, int saltlen, return 0; } } - if (!saltlen) + if (saltlen == 0) saltlen = PKCS12_SALT_LEN; - if (saltlen < 0) + else if (saltlen < 0) return 0; if ((p12->mac->salt->data = OPENSSL_malloc(saltlen)) == NULL) { ERR_raise(ERR_LIB_PKCS12, ERR_R_MALLOC_FAILURE); return 0; } p12->mac->salt->length = saltlen; - if (!salt) { - if (saltlen < 0) - return 0; + if (salt == NULL) { if (RAND_bytes_ex(p12->authsafes->ctx.libctx, p12->mac->salt->data, (size_t)saltlen, 0) <= 0) return 0; - } else + } else { memcpy(p12->mac->salt->data, salt, saltlen); + } X509_SIG_getm(p12->mac->dinfo, &macalg, NULL); if (!X509_ALGOR_set0(macalg, OBJ_nid2obj(EVP_MD_get_type(md_type)), V_ASN1_NULL, NULL)) { |