From edaafacf36d485eff168dff66496fe849fdf3fd5 Mon Sep 17 00:00:00 2001 From: Petr Mensik Date: Sat, 24 Feb 2018 10:47:35 -0800 Subject: [PATCH] Do not assign NULL conditionally in OpenSSL < 1.1, make it always explicit. --- lib/dns/dst_openssl.h | 4 +--- lib/dns/openssldh_link.c | 2 +- lib/dns/openssldsa_link.c | 1 + lib/dns/opensslrsa_link.c | 5 ++++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/dns/dst_openssl.h b/lib/dns/dst_openssl.h index c1a3aa27a4..c9cb939dd6 100644 --- a/lib/dns/dst_openssl.h +++ b/lib/dns/dst_openssl.h @@ -9,8 +9,6 @@ * information regarding copyright ownership. */ -/* $Id: dst_openssl.h,v 1.11 2011/03/12 04:59:48 tbox Exp $ */ - #ifndef DST_OPENSSL_H #define DST_OPENSSL_H 1 @@ -41,7 +39,7 @@ * _cb; * #endif */ -#define BN_GENCB_free(x) (x = NULL); +#define BN_GENCB_free(x) ((void)0) #define BN_GENCB_new() (&_cb) #define BN_GENCB_get_arg(x) ((x)->arg) #endif diff --git a/lib/dns/openssldh_link.c b/lib/dns/openssldh_link.c index 72ac350f20..e74bee2e2d 100644 --- a/lib/dns/openssldh_link.c +++ b/lib/dns/openssldh_link.c @@ -25,7 +25,6 @@ /* * Principal Author: Brian Wellington - * $Id: openssldh_link.c,v 1.20 2011/01/11 23:47:13 tbox Exp $ */ #ifdef OPENSSL @@ -308,6 +307,7 @@ openssldh_generate(dst_key_t *key, int generator, void (*callback)(int)) { DST_R_OPENSSLFAILURE)); } BN_GENCB_free(cb); + cb = NULL; #else dh = DH_generate_parameters(key->key_size, generator, NULL, NULL); diff --git a/lib/dns/openssldsa_link.c b/lib/dns/openssldsa_link.c index f628d9d660..1c541ae73a 100644 --- a/lib/dns/openssldsa_link.c +++ b/lib/dns/openssldsa_link.c @@ -487,6 +487,7 @@ openssldsa_generate(dst_key_t *key, int unused, void (*callback)(int)) { DST_R_OPENSSLFAILURE)); } BN_GENCB_free(cb); + cb = NULL; #else dsa = DSA_generate_parameters(key->key_size, rand_array, ISC_SHA1_DIGESTLENGTH, NULL, NULL, diff --git a/lib/dns/opensslrsa_link.c b/lib/dns/opensslrsa_link.c index f62fae70cd..fd6add864c 100644 --- a/lib/dns/opensslrsa_link.c +++ b/lib/dns/opensslrsa_link.c @@ -1043,6 +1043,7 @@ opensslrsa_generate(dst_key_t *key, int exp, void (*callback)(int)) { if (RSA_generate_key_ex(rsa, key->key_size, e, cb)) { BN_free(e); BN_GENCB_free(cb); + cb = NULL; SET_FLAGS(rsa); #if USE_EVP key->keydata.pkey = pkey; @@ -1065,8 +1066,10 @@ opensslrsa_generate(dst_key_t *key, int exp, void (*callback)(int)) { BN_free(e); if (rsa != NULL) RSA_free(rsa); - if (cb != NULL) + if (cb != NULL) { BN_GENCB_free(cb); + cb = NULL; + } return (dst__openssl_toresult(ret)); #else RSA *rsa;