Check return from BN_set_word.
authorPauli <paul.dale@oracle.com>
Thu, 28 Jun 2018 23:55:23 +0000 (09:55 +1000)
committerPauli <paul.dale@oracle.com>
Fri, 29 Jun 2018 03:25:49 +0000 (13:25 +1000)
In ssl/t1_lib.c.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6613)

(cherry picked from commit 8eab767a718f44ccba9888eeb81a5328cff47bab)

ssl/t1_lib.c

index 3dddd9c2970d33c8822bc92139d3453192a7ce1c..95711fb6df87764fcf614066295a756f449f4546 100644 (file)
@@ -4141,13 +4141,16 @@ DH *ssl_get_auto_dh(SSL *s)
         if (dhp == NULL)
             return NULL;
         g = BN_new();
-        if (g != NULL)
-            BN_set_word(g, 2);
+        if (g == NULL || !BN_set_word(g, 2)) {
+            DH_free(dhp);
+            BN_free(g);
+            return NULL;
+        }
         if (dh_secbits >= 192)
             p = BN_get_rfc3526_prime_8192(NULL);
         else
             p = BN_get_rfc3526_prime_3072(NULL);
-        if (p == NULL || g == NULL || !DH_set0_pqg(dhp, p, NULL, g)) {
+        if (p == NULL || !DH_set0_pqg(dhp, p, NULL, g)) {
             DH_free(dhp);
             BN_free(p);
             BN_free(g);