diff options
author | Pauli <pauli@openssl.org> | 2021-03-29 12:30:40 +1000 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2021-03-30 18:57:29 +0200 |
commit | ec3dd97019b7ec95b77d50b6f81c8d32d58d9bbf (patch) | |
tree | 73eec56d3d6adde3ac5963a8c22464f2a737bfe7 /crypto/evp/evp_pkey.c | |
parent | d0ea0eb331176bf5882e31c8cf2538af16ef76cb (diff) |
evp: fix coverity 1474469: negative return
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14716)
Diffstat (limited to 'crypto/evp/evp_pkey.c')
-rw-r--r-- | crypto/evp/evp_pkey.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/crypto/evp/evp_pkey.c b/crypto/evp/evp_pkey.c index 7aafd76822..35de85cffd 100644 --- a/crypto/evp/evp_pkey.c +++ b/crypto/evp/evp_pkey.c @@ -73,8 +73,9 @@ EVP_PKEY *EVP_PKCS82PKEY_ex(const PKCS8_PRIV_KEY_INFO *p8, OSSL_LIB_CTX *libctx, size_t len; OSSL_DECODER_CTX *dctx = NULL; - if ((encoded_len = i2d_PKCS8_PRIV_KEY_INFO(p8, &encoded_data)) <= 0) - goto end; + if ((encoded_len = i2d_PKCS8_PRIV_KEY_INFO(p8, &encoded_data)) <= 0 + || encoded_data == NULL) + return NULL; p8_data = encoded_data; len = encoded_len; @@ -85,7 +86,6 @@ EVP_PKEY *EVP_PKCS82PKEY_ex(const PKCS8_PRIV_KEY_INFO *p8, OSSL_LIB_CTX *libctx, /* try legacy */ pkey = evp_pkcs82pkey_legacy(p8, libctx, propq); - end: OPENSSL_clear_free(encoded_data, encoded_len); OSSL_DECODER_CTX_free(dctx); return pkey; |