From: Vitaly Chikunov <vt@altlinux.org>
Date: Tue, 15 Oct 2019 16:22:45 +0000 (+0300)
Subject: gost_ec_keyx: Fix CID 253282 Dereference null return value
X-Git-Tag: v3.0.0~263^2~2^2~1
X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=a57bcd50c280fd2c48fd28de93dd94023ebdc980;p=openssl-gost%2Fengine.git

gost_ec_keyx: Fix CID 253282 Dereference null return value

`param' is used unconditionally in pkey_GOST_ECcp_encrypt() so we can
unconditionally check (vs in any particular `if' branch) for it's being
non-NULL. This is similar to how pkey_GOST_ECcp_decrypt() works with
`param'.

Closes #174.
---

diff --git a/gost_ec_keyx.c b/gost_ec_keyx.c
index fa068ae..963cd8a 100644
--- a/gost_ec_keyx.c
+++ b/gost_ec_keyx.c
@@ -263,6 +263,8 @@ static int pkey_GOST_ECcp_encrypt(EVP_PKEY_CTX *pctx, unsigned char *out,
             return 0;
         }
     }
+    if (!param)
+        goto err;
     /* Check for private key in the peer_key of context */
     if (sec_key) {
         key_is_ephemeral = 0;