From 302f75887e52bbe0ab7a5806335a0a1264323b07 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Wed, 10 Feb 2016 15:16:06 +0000 Subject: Attempt to log an error if init failed If init failed we'd like to set an error code to indicate that. But if init failed then when the error system tries to load its strings its going to fail again. We could get into an infinite loop. Therefore we just set a single error the first time around. After that no error is set. Reviewed-by: Rich Salz --- ssl/ssl_init.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'ssl/ssl_init.c') diff --git a/ssl/ssl_init.c b/ssl/ssl_init.c index 134aa00d54..e7fc63dd11 100644 --- a/ssl/ssl_init.c +++ b/ssl/ssl_init.c @@ -301,8 +301,20 @@ static void ssl_library_stop(void) */ int OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings) { - if (stopped) + static int stoperrset = 0; + + if (stopped) { + if (!stoperrset) { + /* + * We only ever set this once to avoid getting into an infinite + * loop where the error system keeps trying to init and fails so + * sets an error etc + */ + stoperrset = 1; + SSLerr(SSL_F_OPENSSL_INIT_SSL_LIBRARY_START, ERR_R_INIT_FAIL); + } return 0; + } if (!OPENSSL_init_crypto(opts | OPENSSL_INIT_ADD_ALL_CIPHERS | OPENSSL_INIT_ADD_ALL_DIGESTS, settings)) -- cgit v1.2.3