Patch leak in EVP_PKEY2PKCS8() error path
authorjwalch <jeremy.walch@gmail.com>
Thu, 29 Oct 2020 14:52:52 +0000 (10:52 -0400)
committerDmitry Belyavskiy <beldmit@gmail.com>
Fri, 30 Oct 2020 19:38:25 +0000 (22:38 +0300)
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/13278)

crypto/evp/evp_pkey.c

index 9e7c978..b5a8f1c 100644 (file)
@@ -78,7 +78,7 @@ PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(const EVP_PKEY *pkey)
     /* Force a key downgrade if that's possible */
     /* TODO(3.0) Is there a better way for provider-native keys? */
     if (EVP_PKEY_get0(pkey) == NULL)
-        return NULL;
+        goto error;
 
     if (pkey->ameth) {
         if (pkey->ameth->priv_encode) {