Fix error handling in compute_key, BN_CTX_get can return NULL
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Thu, 22 Dec 2016 12:51:27 +0000 (13:51 +0100)
committerRichard Levitte <levitte@openssl.org>
Tue, 24 Jan 2017 17:27:10 +0000 (18:27 +0100)
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2132)
(cherry picked from commit 7928ee4d685b727619555bc1ec0aee805f6fc8c4)

crypto/dh/dh_key.c

index 1d80fb2c5f600e725f09f926eefc7808a8ac84a1..387558f1467c813e0e2a2e6c52778593c6bed100 100644 (file)
@@ -223,6 +223,8 @@ static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
         goto err;
     BN_CTX_start(ctx);
     tmp = BN_CTX_get(ctx);
+    if (tmp == NULL)
+        goto err;
 
     if (dh->priv_key == NULL) {
         DHerr(DH_F_COMPUTE_KEY, DH_R_NO_PRIVATE_VALUE);