void ERR_load_ERR_strings(void) { err_fns_check(); #ifndef OPENSSL_NO_ERR err_load_strings(0,ERR_str_libraries); err_load_strings(0,ERR_str_reasons); err_load_strings(ERR_LIB_SYS,ERR_str_functs); build_SYS_str_reasons(); err_load_strings(ERR_LIB_SYS,SYS_str_reasons); #endif }
void ERR_load_ERR_strings(void) { #ifndef OPENSSL_NO_ERR CRYPTO_THREAD_run_once(&err_string_init, do_err_strings_init); err_load_strings(0, ERR_str_libraries); err_load_strings(0, ERR_str_reasons); err_load_strings(ERR_LIB_SYS, ERR_str_functs); build_SYS_str_reasons(); err_load_strings(ERR_LIB_SYS, SYS_str_reasons); #endif }
int ERR_load_ERR_strings(void) { #ifndef OPENSSL_NO_ERR if (!RUN_ONCE(&err_string_init, do_err_strings_init)) return 0; err_load_strings(0, ERR_str_libraries); err_load_strings(0, ERR_str_reasons); err_load_strings(ERR_LIB_SYS, ERR_str_functs); build_SYS_str_reasons(); err_load_strings(ERR_LIB_SYS, SYS_str_reasons); #endif return 1; }
int ERR_load_strings(int lib, ERR_STRING_DATA *str) { if (ERR_load_ERR_strings() == 0) return 0; err_load_strings(lib, str); return 1; }
int ERR_load_strings_const(const ERR_STRING_DATA *str) { if (ERR_load_ERR_strings() == 0) return 0; err_load_strings(str); return 1; }
static void build_SYS_str_reasons(void) { /* OPENSSL_malloc cannot be used here, use static storage instead */ static char strerror_pool[SPACE_SYS_STR_REASONS]; char *cur = strerror_pool; size_t cnt = 0; static int init = 1; int i; int saveerrno = get_last_sys_error(); CRYPTO_THREAD_write_lock(err_string_lock); if (!init) { CRYPTO_THREAD_unlock(err_string_lock); return; } for (i = 1; i <= NUM_SYS_STR_REASONS; i++) { ERR_STRING_DATA *str = &SYS_str_reasons[i - 1]; str->error = ERR_PACK(ERR_LIB_SYS, 0, i); if (str->string == NULL) { if (openssl_strerror_r(i, cur, sizeof(strerror_pool) - cnt)) { size_t l = strlen(cur); str->string = cur; cnt += l; if (cnt > sizeof(strerror_pool)) cnt = sizeof(strerror_pool); cur += l; /* * VMS has an unusual quirk of adding spaces at the end of * some (most? all?) messages. Lets trim them off. */ while (ossl_isspace(cur[-1])) { cur--; cnt--; } *cur++ = '\0'; cnt++; } } if (str->string == NULL) str->string = "unknown"; } /* * Now we still have SYS_str_reasons[NUM_SYS_STR_REASONS] = {0, NULL}, as * required by ERR_load_strings. */ init = 0; CRYPTO_THREAD_unlock(err_string_lock); /* openssl_strerror_r could change errno, but we want to preserve it */ set_sys_error(saveerrno); err_load_strings(SYS_str_reasons); }
static void build_SYS_str_reasons(void) { /* OPENSSL_malloc cannot be used here, use static storage instead */ static char strerror_tab[NUM_SYS_STR_REASONS][LEN_SYS_STR_REASON]; static int init = 1; int i; CRYPTO_THREAD_write_lock(err_string_lock); if (!init) { CRYPTO_THREAD_unlock(err_string_lock); return; } for (i = 1; i <= NUM_SYS_STR_REASONS; i++) { ERR_STRING_DATA *str = &SYS_str_reasons[i - 1]; str->error = ERR_PACK(ERR_LIB_SYS, 0, i); if (str->string == NULL) { char (*dest)[LEN_SYS_STR_REASON] = &(strerror_tab[i - 1]); if (openssl_strerror_r(i, *dest, sizeof(*dest))) str->string = *dest; } if (str->string == NULL) str->string = "unknown"; } /* * Now we still have SYS_str_reasons[NUM_SYS_STR_REASONS] = {0, NULL}, as * required by ERR_load_strings. */ init = 0; CRYPTO_THREAD_unlock(err_string_lock); err_load_strings(SYS_str_reasons); }
void ERR_load_strings(int lib, ERR_STRING_DATA *str) { ERR_load_ERR_strings(); err_load_strings(lib, str); }
void ERR_load_crypto_strings() { err_load_strings(); }