diff options
author | Matt Caswell <matt@openssl.org> | 2016-02-10 15:16:06 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-02-10 17:40:59 +0000 |
commit | 302f75887e52bbe0ab7a5806335a0a1264323b07 (patch) | |
tree | 704e3638b402a89e064f6cde7d893ad8b687581e /crypto/init.c | |
parent | 0fc32b0718ec210e03b6d8623d4819ed04615a1b (diff) |
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 <rsalz@openssl.org>
Diffstat (limited to 'crypto/init.c')
-rw-r--r-- | crypto/init.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/crypto/init.c b/crypto/init.c index f01bd4d93f..cb9d65a4dd 100644 --- a/crypto/init.c +++ b/crypto/init.c @@ -628,8 +628,21 @@ static const OPENSSL_INIT_SETTINGS *ossl_init_get_setting( */ int OPENSSL_init_crypto(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; + CRYPTOerr(CRYPTO_F_OPENSSL_INIT_CRYPTO_LIBRARY_START, + ERR_R_INIT_FAIL); + } return 0; + } ossl_init_once_run(&base, ossl_init_base); |