diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2020-12-21 15:52:01 +0100 |
---|---|---|
committer | Dr. David von Oheimb <dev@ddvo.net> | 2021-01-13 11:53:15 +0100 |
commit | 7836f949c2550a00fe2720e96cfaffd824d357d1 (patch) | |
tree | 89e547dcc181ef97836282e22062d0f2699e7893 /crypto/x509/x_pubkey.c | |
parent | 855c68163b182960f2b27bb961a323944d96237e (diff) |
X509_PUBKEY_set(): Fix error reporting
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/13658)
Diffstat (limited to 'crypto/x509/x_pubkey.c')
-rw-r--r-- | crypto/x509/x_pubkey.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/crypto/x509/x_pubkey.c b/crypto/x509/x_pubkey.c index a9beef682b..7423b122d3 100644 --- a/crypto/x509/x_pubkey.c +++ b/crypto/x509/x_pubkey.c @@ -99,11 +99,10 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey) { X509_PUBKEY *pk = NULL; - if (x == NULL) + if (x == NULL || pkey == NULL) { + ERR_raise(ERR_LIB_X509, ERR_R_PASSED_NULL_PARAMETER); return 0; - - if (pkey == NULL) - goto unsupported; + } if (pkey->ameth != NULL) { if ((pk = X509_PUBKEY_new()) == NULL) { @@ -137,8 +136,10 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey) OPENSSL_free(der); } - if (pk == NULL) - goto unsupported; + if (pk == NULL) { + ERR_raise(ERR_LIB_X509, X509_R_UNSUPPORTED_ALGORITHM); + goto error; + } X509_PUBKEY_free(*x); if (!EVP_PKEY_up_ref(pkey)) { @@ -165,9 +166,6 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey) pk->pkey = pkey; return 1; - unsupported: - ERR_raise(ERR_LIB_X509, X509_R_UNSUPPORTED_ALGORITHM); - error: X509_PUBKEY_free(pk); return 0; |