diff options
author | Kurt Roeckx <kurt@roeckx.be> | 2016-07-12 15:50:06 +0200 |
---|---|---|
committer | Kurt Roeckx <kurt@roeckx.be> | 2016-07-20 19:20:53 +0200 |
commit | 69588edbaa424beb71c6a9b1be416588232cb78c (patch) | |
tree | bc2d601241ea428fac0bc35d215b3964f0fce199 | |
parent | 8cc44d970ced1004db0727d7a7b3e2709c442e55 (diff) |
Check for errors allocating the error strings.
Reviewed-by: Richard Levitte <levitte@openssl.org>
GH: #1330
65 files changed, 149 insertions, 108 deletions
diff --git a/crypto/asn1/asn1_err.c b/crypto/asn1/asn1_err.c index a363fdb2d1..97c3dec923 100644 --- a/crypto/asn1/asn1_err.c +++ b/crypto/asn1/asn1_err.c @@ -32,6 +32,7 @@ static ERR_STRING_DATA ASN1_str_functs[] = { {ERR_FUNC(ASN1_F_ASN1_D2I_READ_BIO), "asn1_d2i_read_bio"}, {ERR_FUNC(ASN1_F_ASN1_DIGEST), "ASN1_digest"}, {ERR_FUNC(ASN1_F_ASN1_DO_ADB), "asn1_do_adb"}, + {ERR_FUNC(ASN1_F_ASN1_DO_LOCK), "asn1_do_lock"}, {ERR_FUNC(ASN1_F_ASN1_DUP), "ASN1_dup"}, {ERR_FUNC(ASN1_F_ASN1_EX_C2I), "asn1_ex_c2i"}, {ERR_FUNC(ASN1_F_ASN1_FIND_END), "asn1_find_end"}, @@ -253,7 +254,7 @@ static ERR_STRING_DATA ASN1_str_reasons[] = { #endif -void ERR_load_ASN1_strings(void) +int ERR_load_ASN1_strings(void) { #ifndef OPENSSL_NO_ERR @@ -262,4 +263,5 @@ void ERR_load_ASN1_strings(void) ERR_load_strings(0, ASN1_str_reasons); } #endif + return 1; } diff --git a/crypto/async/async_err.c b/crypto/async/async_err.c index 13c41cdd28..ae97e96533 100644 --- a/crypto/async/async_err.c +++ b/crypto/async/async_err.c @@ -38,7 +38,7 @@ static ERR_STRING_DATA ASYNC_str_reasons[] = { #endif -void ERR_load_ASYNC_strings(void) +int ERR_load_ASYNC_strings(void) { #ifndef OPENSSL_NO_ERR @@ -47,4 +47,5 @@ void ERR_load_ASYNC_strings(void) ERR_load_strings(0, ASYNC_str_reasons); } #endif + return 1; } diff --git a/crypto/bio/bio_err.c b/crypto/bio/bio_err.c index 75531824c3..d032dedbb7 100644 --- a/crypto/bio/bio_err.c +++ b/crypto/bio/bio_err.c @@ -112,7 +112,7 @@ static ERR_STRING_DATA BIO_str_reasons[] = { #endif -void ERR_load_BIO_strings(void) +int ERR_load_BIO_strings(void) { #ifndef OPENSSL_NO_ERR @@ -121,4 +121,5 @@ void ERR_load_BIO_strings(void) ERR_load_strings(0, BIO_str_reasons); } #endif + return 1; } diff --git a/crypto/bn/bn_err.c b/crypto/bn/bn_err.c index a71b265de2..5fe9db9ede 100644 --- a/crypto/bn/bn_err.c +++ b/crypto/bn/bn_err.c @@ -94,7 +94,7 @@ static ERR_STRING_DATA BN_str_reasons[] = { #endif -void ERR_load_BN_strings(void) +int ERR_load_BN_strings(void) { #ifndef OPENSSL_NO_ERR @@ -103,4 +103,5 @@ void ERR_load_BN_strings(void) ERR_load_strings(0, BN_str_reasons); } #endif + return 1; } diff --git a/crypto/buffer/buf_err.c b/crypto/buffer/buf_err.c index b7679ae064..a6a2ab88ae 100644 --- a/crypto/buffer/buf_err.c +++ b/crypto/buffer/buf_err.c @@ -31,7 +31,7 @@ static ERR_STRING_DATA BUF_str_reasons[] = { #endif -void ERR_load_BUF_strings(void) +int ERR_load_BUF_strings(void) { #ifndef OPENSSL_NO_ERR @@ -40,4 +40,5 @@ void ERR_load_BUF_strings(void) ERR_load_strings(0, BUF_str_reasons); } #endif + return 1; } diff --git a/crypto/cms/cms_err.c b/crypto/cms/cms_err.c index cfda0190c2..c6df1b5afe 100644 --- a/crypto/cms/cms_err.c +++ b/crypto/cms/cms_err.c @@ -245,7 +245,7 @@ static ERR_STRING_DATA CMS_str_reasons[] = { #endif -void ERR_load_CMS_strings(void) +int ERR_load_CMS_strings(void) { #ifndef OPENSSL_NO_ERR @@ -254,4 +254,5 @@ void ERR_load_CMS_strings(void) ERR_load_strings(0, CMS_str_reasons); } #endif + return 1; } diff --git a/crypto/comp/comp_err.c b/crypto/comp/comp_err.c index 0233e940f6..8e2e69568d 100644 --- a/crypto/comp/comp_err.c +++ b/crypto/comp/comp_err.c @@ -35,7 +35,7 @@ static ERR_STRING_DATA COMP_str_reasons[] = { #endif -void ERR_load_COMP_strings(void) +int ERR_load_COMP_strings(void) { #ifndef OPENSSL_NO_ERR @@ -44,4 +44,5 @@ void ERR_load_COMP_strings(void) ERR_load_strings(0, COMP_str_reasons); } #endif + return 1; } diff --git a/crypto/conf/conf_err.c b/crypto/conf/conf_err.c index 31bb15c34a..b583c057cd 100644 --- a/crypto/conf/conf_err.c +++ b/crypto/conf/conf_err.c @@ -66,7 +66,7 @@ static ERR_STRING_DATA CONF_str_reasons[] = { #endif -void ERR_load_CONF_strings(void) +int ERR_load_CONF_strings(void) { #ifndef OPENSSL_NO_ERR @@ -75,4 +75,5 @@ void ERR_load_CONF_strings(void) ERR_load_strings(0, CONF_str_reasons); } #endif + return 1; } diff --git a/crypto/cpt_err.c b/crypto/cpt_err.c index 3c6e8d53d2..c28dcf19a7 100644 --- a/crypto/cpt_err.c +++ b/crypto/cpt_err.c @@ -42,7 +42,7 @@ static ERR_STRING_DATA CRYPTO_str_reasons[] = { #endif -void ERR_load_CRYPTO_strings(void) +int ERR_load_CRYPTO_strings(void) { #ifndef OPENSSL_NO_ERR @@ -51,4 +51,5 @@ void ERR_load_CRYPTO_strings(void) ERR_load_strings(0, CRYPTO_str_reasons); } #endif + return 1; } diff --git a/crypto/ct/ct_err.c b/crypto/ct/ct_err.c index 8581dbb791..dbf0bd2b11 100644 --- a/crypto/ct/ct_err.c +++ b/crypto/ct/ct_err.c @@ -25,6 +25,8 @@ static ERR_STRING_DATA CT_str_functs[] = { {ERR_FUNC(CT_F_CTLOG_NEW_NULL), "CTLOG_new_null"}, {ERR_FUNC(CT_F_CTLOG_STORE_LOAD_CTX_NEW), "ctlog_store_load_ctx_new"}, {ERR_FUNC(CT_F_CTLOG_STORE_LOAD_FILE), "CTLOG_STORE_load_file"}, + {ERR_FUNC(CT_F_CTLOG_STORE_LOAD_LOG), "ctlog_store_load_log"}, + {ERR_FUNC(CT_F_CTLOG_STORE_NEW), "CTLOG_STORE_new"}, {ERR_FUNC(CT_F_CT_BASE64_DECODE), "ct_base64_decode"}, {ERR_FUNC(CT_F_CT_POLICY_EVAL_CTX_NEW), "CT_POLICY_EVAL_CTX_new"}, {ERR_FUNC(CT_F_CT_V1_LOG_ID_FROM_PKEY), "ct_v1_log_id_from_pkey"}, @@ -73,7 +75,7 @@ static ERR_STRING_DATA CT_str_reasons[] = { #endif -void ERR_load_CT_strings(void) +int ERR_load_CT_strings(void) { #ifndef OPENSSL_NO_ERR @@ -82,4 +84,5 @@ void ERR_load_CT_strings(void) ERR_load_strings(0, CT_str_reasons); } #endif + return 1; } diff --git a/crypto/dh/dh_err.c b/crypto/dh/dh_err.c index a5348b1aab..4e21f284bd 100644 --- a/crypto/dh/dh_err.c +++ b/crypto/dh/dh_err.c @@ -60,7 +60,7 @@ static ERR_STRING_DATA DH_str_reasons[] = { #endif -void ERR_load_DH_strings(void) +int ERR_load_DH_strings(void) { #ifndef OPENSSL_NO_ERR @@ -69,4 +69,5 @@ void ERR_load_DH_strings(void) ERR_load_strings(0, DH_str_reasons); } #endif + return 1; } diff --git a/crypto/dsa/dsa_err.c b/crypto/dsa/dsa_err.c index 028f79f32a..6de49eebbd 100644 --- a/crypto/dsa/dsa_err.c +++ b/crypto/dsa/dsa_err.c @@ -61,7 +61,7 @@ static ERR_STRING_DATA DSA_str_reasons[] = { #endif -void ERR_load_DSA_strings(void) +int ERR_load_DSA_strings(void) { #ifndef OPENSSL_NO_ERR @@ -70,4 +70,5 @@ void ERR_load_DSA_strings(void) ERR_load_strings(0, DSA_str_reasons); } #endif + return 1; } diff --git a/crypto/dso/dso_err.c b/crypto/dso/dso_err.c index 870c80beb0..a180580759 100644 --- a/crypto/dso/dso_err.c +++ b/crypto/dso/dso_err.c @@ -78,7 +78,7 @@ static ERR_STRING_DATA DSO_str_reasons[] = { #endif -void ERR_load_DSO_strings(void) +int ERR_load_DSO_strings(void) { #ifndef OPENSSL_NO_ERR @@ -87,4 +87,5 @@ void ERR_load_DSO_strings(void) ERR_load_strings(0, DSO_str_reasons); } #endif + return 1; } diff --git a/crypto/ec/ec_err.c b/crypto/ec/ec_err.c index 25dea231b8..39e8343623 100644 --- a/crypto/ec/ec_err.c +++ b/crypto/ec/ec_err.c @@ -271,7 +271,7 @@ static ERR_STRING_DATA EC_str_reasons[] = { #endif -void ERR_load_EC_strings(void) +int ERR_load_EC_strings(void) { #ifndef OPENSSL_NO_ERR @@ -280,4 +280,5 @@ void ERR_load_EC_strings(void) ERR_load_strings(0, EC_str_reasons); } #endif + return 1; } diff --git a/crypto/engine/eng_err.c b/crypto/engine/eng_err.c index 5eb8771969..5e9d16f3cd 100644 --- a/crypto/engine/eng_err.c +++ b/crypto/engine/eng_err.c @@ -110,7 +110,7 @@ static ERR_STRING_DATA ENGINE_str_reasons[] = { #endif -void ERR_load_ENGINE_strings(void) +int ERR_load_ENGINE_strings(void) { #ifndef OPENSSL_NO_ERR @@ -119,4 +119,5 @@ void ERR_load_ENGINE_strings(void) ERR_load_strings(0, ENGINE_str_reasons); } #endif + return 1; } diff --git a/crypto/err/err.c b/crypto/err/err.c index ad1ccd10d0..dc721c2e08 100644 --- a/crypto/err/err.c +++ b/crypto/err/err.c @@ -283,10 +283,11 @@ void err_cleanup(void) err_string_lock = NULL; } -void ERR_load_ERR_strings(void) +int ERR_load_ERR_strings(void) { #ifndef OPENSSL_NO_ERR - RUN_ONCE(&err_string_init, do_err_strings_init); + 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); @@ -294,6 +295,7 @@ void ERR_load_ERR_strings(void) build_SYS_str_reasons(); err_load_strings(ERR_LIB_SYS, SYS_str_reasons); #endif + return 1; } static void err_load_strings(int lib, ERR_STRING_DATA *str) @@ -312,10 +314,12 @@ static void err_load_strings(int lib, ERR_STRING_DATA *str) CRYPTO_THREAD_unlock(err_string_lock); } -void ERR_load_strings(int lib, ERR_STRING_DATA *str) +int ERR_load_strings(int lib, ERR_STRING_DATA *str) { - ERR_load_ERR_strings(); + if (ERR_load_ERR_strings() == 0) + return 0; err_load_strings(lib, str); + return 1; } int ERR_unload_strings(int lib, ERR_STRING_DATA *str) diff --git a/crypto/err/err_all.c b/crypto/err/err_all.c index f617dd1a0d..3b1304f8e0 100644 --- a/crypto/err/err_all.c +++ b/crypto/err/err_all.c @@ -40,66 +40,70 @@ #include <openssl/async.h> #include <openssl/kdf.h> -void err_load_crypto_strings_int(void) +int err_load_crypto_strings_int(void) { + if ( #ifdef OPENSSL_FIPS - FIPS_set_error_callbacks(ERR_put_error, ERR_add_error_vdata); + FIPS_set_error_callbacks(ERR_put_error, ERR_add_error_vdata) == 0 || #endif #ifndef OPENSSL_NO_ERR - ERR_load_ERR_strings(); /* include error strings for SYSerr */ - ERR_load_BN_strings(); + ERR_load_ERR_strings() == 0 || /* include error strings for SYSerr */ + ERR_load_BN_strings() == 0 || # ifndef OPENSSL_NO_RSA - ERR_load_RSA_strings(); + ERR_load_RSA_strings() == 0 || # endif # ifndef OPENSSL_NO_DH - ERR_load_DH_strings(); + ERR_load_DH_strings() == 0 || # endif - ERR_load_EVP_strings(); - ERR_load_BUF_strings(); - ERR_load_OBJ_strings(); - ERR_load_PEM_strings(); + ERR_load_EVP_strings() == 0 || + ERR_load_BUF_strings() == 0 || + ERR_load_OBJ_strings() == 0 || + ERR_load_PEM_strings() == 0 || # ifndef OPENSSL_NO_DSA - ERR_load_DSA_strings(); + ERR_load_DSA_strings() == 0 || # endif - ERR_load_X509_strings(); - ERR_load_ASN1_strings(); - ERR_load_CONF_strings(); - ERR_load_CRYPTO_strings(); + ERR_load_X509_strings() == 0 || + ERR_load_ASN1_strings() == 0 || + ERR_load_CONF_strings() == 0 || + ERR_load_CRYPTO_strings() == 0 || # ifndef OPENSSL_NO_COMP - ERR_load_COMP_strings(); + ERR_load_COMP_strings() == 0 || # endif # ifndef OPENSSL_NO_EC - ERR_load_EC_strings(); + ERR_load_EC_strings() == 0 || # endif - /* skip ERR_load_SSL_strings() because it is not in this library */ - ERR_load_BIO_strings(); - ERR_load_PKCS7_strings(); - ERR_load_X509V3_strings(); - ERR_load_PKCS12_strings(); - ERR_load_RAND_strings(); - ERR_load_DSO_strings(); + /* skip ERR_load_SSL_strings() because it is not in this library */ + ERR_load_BIO_strings() == 0 || + ERR_load_PKCS7_strings() == 0 || + ERR_load_X509V3_strings() == 0 || + ERR_load_PKCS12_strings() == 0 || + ERR_load_RAND_strings() == 0 || + ERR_load_DSO_strings() == 0 || # ifndef OPENSSL_NO_TS - ERR_load_TS_strings(); + ERR_load_TS_strings() == 0 || # endif # ifndef OPENSSL_NO_ENGINE - ERR_load_ENGINE_strings(); + ERR_load_ENGINE_strings() == 0 || # endif # ifndef OPENSSL_NO_OCSP - ERR_load_OCSP_strings(); + ERR_load_OCSP_strings() == 0 || # endif #ifndef OPENSSL_NO_UI - ERR_load_UI_strings(); + ERR_load_UI_strings() == 0 || #endif # ifdef OPENSSL_FIPS - ERR_load_FIPS_strings(); + ERR_load_FIPS_strings() == 0 || # endif # ifndef OPENSSL_NO_CMS - ERR_load_CMS_strings(); + ERR_load_CMS_strings() == 0 || # endif # ifndef OPENSSL_NO_CT - ERR_load_CT_strings(); + ERR_load_CT_strings() == 0 || # endif - ERR_load_ASYNC_strings(); + ERR_load_ASYNC_strings() == 0 || #endif - ERR_load_KDF_strings(); + ERR_load_KDF_strings() == 0) + return 0; + + return 1; } diff --git a/crypto/evp/evp_err.c b/crypto/evp/evp_err.c index 50277ffb82..bde5e31e91 100644 --- a/crypto/evp/evp_err.c +++ b/crypto/evp/evp_err.c @@ -57,10 +57,10 @@ static ERR_STRING_DATA EVP_str_functs[] = { {ERR_FUNC(EVP_F_EVP_PKEY_ENCRYPT), "EVP_PKEY_encrypt"}, {ERR_FUNC(EVP_F_EVP_PKEY_ENCRYPT_INIT), "EVP_PKEY_encrypt_init"}, {ERR_FUNC(EVP_F_EVP_PKEY_ENCRYPT_OLD), "EVP_PKEY_encrypt_old"}, - {ERR_FUNC(EVP_F_EVP_PKEY_GET0_HMAC), "EVP_PKEY_get0_hmac"}, {ERR_FUNC(EVP_F_EVP_PKEY_GET0_DH), "EVP_PKEY_get0_DH"}, {ERR_FUNC(EVP_F_EVP_PKEY_GET0_DSA), "EVP_PKEY_get0_DSA"}, {ERR_FUNC(EVP_F_EVP_PKEY_GET0_EC_KEY), "EVP_PKEY_get0_EC_KEY"}, + {ERR_FUNC(EVP_F_EVP_PKEY_GET0_HMAC), "EVP_PKEY_get0_hmac"}, {ERR_FUNC(EVP_F_EVP_PKEY_GET0_RSA), "EVP_PKEY_get0_RSA"}, {ERR_FUNC(EVP_F_EVP_PKEY_KEYGEN), "EVP_PKEY_keygen"}, {ERR_FUNC(EVP_F_EVP_PKEY_KEYGEN_INIT), "EVP_PKEY_keygen_init"}, @@ -159,7 +159,7 @@ static ERR_STRING_DATA EVP_str_reasons[] = { #endif -void ERR_load_EVP_strings(void) +int ERR_load_EVP_strings(void) { #ifndef OPENSSL_NO_ERR @@ -168,4 +168,5 @@ void ERR_load_EVP_strings(void) ERR_load_strings(0, EVP_str_reasons); } #endif + return 1; } diff --git a/crypto/include/internal/err_int.h b/crypto/include/internal/err_int.h index 749a8db262..7fec3ed767 100644 --- a/crypto/include/internal/err_int.h +++ b/crypto/include/internal/err_int.h @@ -10,7 +10,7 @@ #ifndef INTERNAL_ERR_INT_H # define INTERNAL_ERR_INT_H -void err_load_crypto_strings_int(void); +int err_load_crypto_strings_int(void); void err_cleanup(void); void err_delete_thread_state(void); diff --git a/crypto/init.c b/crypto/init.c index ace11da610..332567eae7 100644 --- a/crypto/init.c +++ b/crypto/init.c @@ -92,6 +92,7 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_no_load_crypto_strings) DEFINE_RUN_ONCE_STATIC(ossl_init_load_crypto_strings) { + int ret = 1; /* * OPENSSL_NO_AUTOERRINIT is provided here to prevent at compile time * pulling in all the error strings during static linking @@ -101,10 +102,10 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_load_crypto_strings) fprintf(stderr, "OPENSSL_INIT: ossl_init_load_crypto_strings: " "err_load_crypto_strings_int()\n"); # endif - err_load_crypto_strings_int(); + ret = err_load_crypto_strings_int(); #endif load_crypto_strings_inited = 1; - return 1; + return ret; } static CRYPTO_ONCE add_all_ciphers = CRYPTO_ONCE_STATIC_INIT; diff --git a/crypto/kdf/kdf_err.c b/crypto/kdf/kdf_err.c index 6707a52ba7..d7d71b35e4 100644 --- a/crypto/kdf/kdf_err.c +++ b/crypto/kdf/kdf_err.c @@ -33,7 +33,7 @@ static ERR_STRING_DATA KDF_str_reasons[] = { #endif -void ERR_load_KDF_strings(void) +int ERR_load_KDF_strings(void) { #ifndef OPENSSL_NO_ERR @@ -42,4 +42,5 @@ void ERR_load_KDF_strings(void) |