diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/err/err.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/lib/libcrypto/err/err.c b/src/lib/libcrypto/err/err.c index ffe25bf465..320078da66 100644 --- a/src/lib/libcrypto/err/err.c +++ b/src/lib/libcrypto/err/err.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: err.c,v 1.45 2017/02/20 23:21:19 beck Exp $ */ | 1 | /* $OpenBSD: err.c,v 1.46 2018/03/17 16:20:01 beck Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -109,6 +109,7 @@ | |||
| 109 | * | 109 | * |
| 110 | */ | 110 | */ |
| 111 | 111 | ||
| 112 | #include <pthread.h> | ||
| 112 | #include <stdarg.h> | 113 | #include <stdarg.h> |
| 113 | #include <stdio.h> | 114 | #include <stdio.h> |
| 114 | #include <string.h> | 115 | #include <string.h> |
| @@ -282,6 +283,8 @@ static LHASH_OF(ERR_STATE) *int_thread_hash = NULL; | |||
| 282 | static int int_thread_hash_references = 0; | 283 | static int int_thread_hash_references = 0; |
| 283 | static int int_err_library_number = ERR_LIB_USER; | 284 | static int int_err_library_number = ERR_LIB_USER; |
| 284 | 285 | ||
| 286 | static pthread_t err_init_thread; | ||
| 287 | |||
| 285 | /* Internal function that checks whether "err_fns" is set and if not, sets it to | 288 | /* Internal function that checks whether "err_fns" is set and if not, sets it to |
| 286 | * the defaults. */ | 289 | * the defaults. */ |
| 287 | static void | 290 | static void |
| @@ -650,8 +653,9 @@ ERR_STATE_free(ERR_STATE *s) | |||
| 650 | } | 653 | } |
| 651 | 654 | ||
| 652 | void | 655 | void |
| 653 | ERR_load_ERR_strings(void) | 656 | ERR_load_ERR_strings_internal(void) |
| 654 | { | 657 | { |
| 658 | err_init_thread = pthread_self(); | ||
| 655 | err_fns_check(); | 659 | err_fns_check(); |
| 656 | #ifndef OPENSSL_NO_ERR | 660 | #ifndef OPENSSL_NO_ERR |
| 657 | err_load_strings(0, ERR_str_libraries); | 661 | err_load_strings(0, ERR_str_libraries); |
| @@ -662,6 +666,21 @@ ERR_load_ERR_strings(void) | |||
| 662 | #endif | 666 | #endif |
| 663 | } | 667 | } |
| 664 | 668 | ||
| 669 | |||
| 670 | void | ||
| 671 | ERR_load_ERR_strings(void) | ||
| 672 | { | ||
| 673 | static pthread_once_t once = PTHREAD_ONCE_INIT; | ||
| 674 | |||
| 675 | if (pthread_equal(pthread_self(), err_init_thread)) | ||
| 676 | return; /* don't recurse */ | ||
| 677 | |||
| 678 | /* Prayer and clean living lets you ignore errors, OpenSSL style */ | ||
| 679 | (void) OPENSSL_init_crypto(0, NULL); | ||
| 680 | |||
| 681 | (void) pthread_once(&once, ERR_load_ERR_strings_internal); | ||
| 682 | } | ||
| 683 | |||
| 665 | static void | 684 | static void |
| 666 | err_load_strings(int lib, ERR_STRING_DATA *str) | 685 | err_load_strings(int lib, ERR_STRING_DATA *str) |
| 667 | { | 686 | { |
| @@ -683,6 +702,9 @@ ERR_load_strings(int lib, ERR_STRING_DATA *str) | |||
| 683 | void | 702 | void |
| 684 | ERR_unload_strings(int lib, ERR_STRING_DATA *str) | 703 | ERR_unload_strings(int lib, ERR_STRING_DATA *str) |
| 685 | { | 704 | { |
| 705 | /* Prayer and clean living lets you ignore errors, OpenSSL style */ | ||
| 706 | (void) OPENSSL_init_crypto(0, NULL); | ||
| 707 | |||
| 686 | while (str->error) { | 708 | while (str->error) { |
| 687 | if (lib) | 709 | if (lib) |
| 688 | str->error |= ERR_PACK(lib, 0, 0); | 710 | str->error |= ERR_PACK(lib, 0, 0); |
| @@ -694,6 +716,9 @@ ERR_unload_strings(int lib, ERR_STRING_DATA *str) | |||
| 694 | void | 716 | void |
| 695 | ERR_free_strings(void) | 717 | ERR_free_strings(void) |
| 696 | { | 718 | { |
| 719 | /* Prayer and clean living lets you ignore errors, OpenSSL style */ | ||
| 720 | (void) OPENSSL_init_crypto(0, NULL); | ||
| 721 | |||
| 697 | err_fns_check(); | 722 | err_fns_check(); |
| 698 | ERRFN(err_del)(); | 723 | ERRFN(err_del)(); |
| 699 | } | 724 | } |
| @@ -953,6 +978,9 @@ ERR_lib_error_string(unsigned long e) | |||
| 953 | ERR_STRING_DATA d, *p; | 978 | ERR_STRING_DATA d, *p; |
| 954 | unsigned long l; | 979 | unsigned long l; |
| 955 | 980 | ||
| 981 | if (!OPENSSL_init_crypto(0, NULL)) | ||
| 982 | return NULL; | ||
| 983 | |||
| 956 | err_fns_check(); | 984 | err_fns_check(); |
| 957 | l = ERR_GET_LIB(e); | 985 | l = ERR_GET_LIB(e); |
| 958 | d.error = ERR_PACK(l, 0, 0); | 986 | d.error = ERR_PACK(l, 0, 0); |
