diff options
| author | beck <> | 2018-03-19 03:35:38 +0000 |
|---|---|---|
| committer | beck <> | 2018-03-19 03:35:38 +0000 |
| commit | 02fd65d9fc788d4e8e18c251840f300031577d70 (patch) | |
| tree | c2587bdba8d5d81576ed1d6536ed36f021b869cf /src/lib/libcrypto/crypto_init.c | |
| parent | ed245d2c282aafe5e3349f16ecc45562fa1c61cf (diff) | |
| download | openbsd-02fd65d9fc788d4e8e18c251840f300031577d70.tar.gz openbsd-02fd65d9fc788d4e8e18c251840f300031577d70.tar.bz2 openbsd-02fd65d9fc788d4e8e18c251840f300031577d70.zip | |
Correct mistake of loading the default openssl.conf by default during autoinit.
This brings in the OPENSSL_INIT_LOAD_CONFIG flag with the same semantics as
OpenSSL. As a result, by default the openssl.conf file is not loaded during
autoinit, which makes autoinit safe for pledge(stdio).
ok jsing@
Diffstat (limited to 'src/lib/libcrypto/crypto_init.c')
| -rw-r--r-- | src/lib/libcrypto/crypto_init.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/lib/libcrypto/crypto_init.c b/src/lib/libcrypto/crypto_init.c index f3d1a2bce9..ed2b5d4810 100644 --- a/src/lib/libcrypto/crypto_init.c +++ b/src/lib/libcrypto/crypto_init.c | |||
| @@ -25,6 +25,9 @@ | |||
| 25 | #include <openssl/err.h> | 25 | #include <openssl/err.h> |
| 26 | #include "cryptlib.h" | 26 | #include "cryptlib.h" |
| 27 | 27 | ||
| 28 | int OpenSSL_config(char *); | ||
| 29 | int OpenSSL_no_config(char *); | ||
| 30 | |||
| 28 | static pthread_t crypto_init_thread; | 31 | static pthread_t crypto_init_thread; |
| 29 | 32 | ||
| 30 | static void | 33 | static void |
| @@ -35,7 +38,6 @@ OPENSSL_init_crypto_internal(void) | |||
| 35 | ERR_load_crypto_strings(); | 38 | ERR_load_crypto_strings(); |
| 36 | OpenSSL_add_all_ciphers(); | 39 | OpenSSL_add_all_ciphers(); |
| 37 | OpenSSL_add_all_digests(); | 40 | OpenSSL_add_all_digests(); |
| 38 | OPENSSL_config(NULL); | ||
| 39 | } | 41 | } |
| 40 | 42 | ||
| 41 | int | 43 | int |
| @@ -46,11 +48,16 @@ OPENSSL_init_crypto(uint64_t opts, const void *settings) | |||
| 46 | if (pthread_equal(pthread_self(), crypto_init_thread)) | 48 | if (pthread_equal(pthread_self(), crypto_init_thread)) |
| 47 | return 1; /* don't recurse */ | 49 | return 1; /* don't recurse */ |
| 48 | 50 | ||
| 49 | if (opts & OPENSSL_INIT_NO_LOAD_CONFIG) | ||
| 50 | OPENSSL_no_config(); | ||
| 51 | |||
| 52 | if (pthread_once(&once, OPENSSL_init_crypto_internal) != 0) | 51 | if (pthread_once(&once, OPENSSL_init_crypto_internal) != 0) |
| 53 | return 0; | 52 | return 0; |
| 54 | 53 | ||
| 54 | if ((opts & OPENSSL_INIT_NO_LOAD_CONFIG) && | ||
| 55 | (OpenSSL_no_config(NULL) == 0)) | ||
| 56 | return 0; | ||
| 57 | |||
| 58 | if ((opts & OPENSSL_INIT_LOAD_CONFIG) && | ||
| 59 | (OpenSSL_config(NULL) == 0)) | ||
| 60 | return 0; | ||
| 61 | |||
| 55 | return 1; | 62 | return 1; |
| 56 | } | 63 | } |
