From: Dr. David von Oheimb Date: Mon, 21 Dec 2020 14:52:01 +0000 (+0100) Subject: X509_PUBKEY_set(): Fix error reporting X-Git-Tag: openssl-3.0.0-alpha11~121 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7836f949c2550a00fe2720e96cfaffd824d357d1;p=thirdparty%2Fopenssl.git X509_PUBKEY_set(): Fix error reporting Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/13658) --- diff --git a/crypto/x509/x_pubkey.c b/crypto/x509/x_pubkey.c index a9beef682bb..7423b122d35 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;