From: Richard Levitte Date: Mon, 14 Nov 2016 22:53:45 +0000 (+0100) Subject: Stop init loops X-Git-Tag: OpenSSL_1_1_0d~143 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f56c786769e13bb06e9855cd426e74a1c9eea3a1;p=openssl Stop init loops Under certain circumstances, the libcrypto init code would loop, causing a deadlock. This would typically happen if something in ossl_init_base() caused an OpenSSL error, and the error stack routines would recurse into the init code before the flag that ossl_init_base() had been run was checked. This change makes sure ossl_init_base isn't run once more of the base is initiated. Thanks to Dmitry Kostjuchenko for the idea. Fixes Github issue #1899 Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/1922) (cherry picked from commit b7a7f39afeb4748b4c25dbccb8951711b8b70eaf) --- diff --git a/crypto/init.c b/crypto/init.c index 411e2d8809..a5b6e5aff4 100644 --- a/crypto/init.c +++ b/crypto/init.c @@ -503,7 +503,7 @@ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings) return 0; } - if (!RUN_ONCE(&base, ossl_init_base)) + if (!base_inited && !RUN_ONCE(&base, ossl_init_base)) return 0; if ((opts & OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS)