Blob Blame History Raw
From 181e736dcbb19c828266d88837f4343510b4d20e Mon Sep 17 00:00:00 2001
From: Oleg Girko <ol@infoserver.lv>
Date: Fri, 22 Sep 2017 22:18:34 +0100
Subject: [PATCH] sx/ssl.c: fix undefined behaviour with openssl-1.1

BN_dec2bn in OpenSSL 1.1 requires its first argument to point to
either pointer to initialised BIGNUM or NULL.
Using pointer to uninitialised pointer to BIGNUM is undefined behaviour
causing coredumps or other memory corruption.

This change fixes missing initialisation overlooked when porting
to OpenSSL 1.1 API.

Signed-off-by: Oleg Girko <ol@infoserver.lv>
---
 sx/ssl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sx/ssl.c b/sx/ssl.c
index 85fb709d..476748f1 100644
--- a/sx/ssl.c
+++ b/sx/ssl.c
@@ -124,7 +124,7 @@ static DH *sx_ssl_make_dh_params(BIGNUM *(*const get_prime)(BIGNUM *), const cha
     }
 #else
     {
-        BIGNUM *p, *g;
+        BIGNUM *p, *g = NULL;
         p = get_prime(NULL);
         BN_dec2bn(&g, gen);