Skip to content

Commit

Permalink
Check for errors allocating the error strings.
Browse files Browse the repository at this point in the history
Reviewed-by: Richard Levitte <[email protected]>
GH: openssl#1330
  • Loading branch information
kroeckx committed Jul 20, 2016
1 parent 8cc44d9 commit 69588ed
Show file tree
Hide file tree
Showing 65 changed files with 149 additions and 108 deletions.
4 changes: 3 additions & 1 deletion crypto/asn1/asn1_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down Expand Up @@ -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

Expand All @@ -262,4 +263,5 @@ void ERR_load_ASN1_strings(void)
ERR_load_strings(0, ASN1_str_reasons);
}
#endif
return 1;
}
3 changes: 2 additions & 1 deletion crypto/async/async_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -47,4 +47,5 @@ void ERR_load_ASYNC_strings(void)
ERR_load_strings(0, ASYNC_str_reasons);
}
#endif
return 1;
}
3 changes: 2 additions & 1 deletion crypto/bio/bio_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -121,4 +121,5 @@ void ERR_load_BIO_strings(void)
ERR_load_strings(0, BIO_str_reasons);
}
#endif
return 1;
}
3 changes: 2 additions & 1 deletion crypto/bn/bn_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -103,4 +103,5 @@ void ERR_load_BN_strings(void)
ERR_load_strings(0, BN_str_reasons);
}
#endif
return 1;
}
3 changes: 2 additions & 1 deletion crypto/buffer/buf_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -40,4 +40,5 @@ void ERR_load_BUF_strings(void)
ERR_load_strings(0, BUF_str_reasons);
}
#endif
return 1;
}
3 changes: 2 additions & 1 deletion crypto/cms/cms_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -254,4 +254,5 @@ void ERR_load_CMS_strings(void)
ERR_load_strings(0, CMS_str_reasons);
}
#endif
return 1;
}
3 changes: 2 additions & 1 deletion crypto/comp/comp_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -44,4 +44,5 @@ void ERR_load_COMP_strings(void)
ERR_load_strings(0, COMP_str_reasons);
}
#endif
return 1;
}
3 changes: 2 additions & 1 deletion crypto/conf/conf_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -75,4 +75,5 @@ void ERR_load_CONF_strings(void)
ERR_load_strings(0, CONF_str_reasons);
}
#endif
return 1;
}
3 changes: 2 additions & 1 deletion crypto/cpt_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -51,4 +51,5 @@ void ERR_load_CRYPTO_strings(void)
ERR_load_strings(0, CRYPTO_str_reasons);
}
#endif
return 1;
}
5 changes: 4 additions & 1 deletion crypto/ct/ct_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down Expand Up @@ -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

Expand All @@ -82,4 +84,5 @@ void ERR_load_CT_strings(void)
ERR_load_strings(0, CT_str_reasons);
}
#endif
return 1;
}
3 changes: 2 additions & 1 deletion crypto/dh/dh_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -69,4 +69,5 @@ void ERR_load_DH_strings(void)
ERR_load_strings(0, DH_str_reasons);
}
#endif
return 1;
}
3 changes: 2 additions & 1 deletion crypto/dsa/dsa_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -70,4 +70,5 @@ void ERR_load_DSA_strings(void)
ERR_load_strings(0, DSA_str_reasons);
}
#endif
return 1;
}
3 changes: 2 additions & 1 deletion crypto/dso/dso_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -87,4 +87,5 @@ void ERR_load_DSO_strings(void)
ERR_load_strings(0, DSO_str_reasons);
}
#endif
return 1;
}
3 changes: 2 additions & 1 deletion crypto/ec/ec_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -280,4 +280,5 @@ void ERR_load_EC_strings(void)
ERR_load_strings(0, EC_str_reasons);
}
#endif
return 1;
}
3 changes: 2 additions & 1 deletion crypto/engine/eng_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -119,4 +119,5 @@ void ERR_load_ENGINE_strings(void)
ERR_load_strings(0, ENGINE_str_reasons);
}
#endif
return 1;
}
12 changes: 8 additions & 4 deletions crypto/err/err.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,17 +283,19 @@ 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);
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;
}

static void err_load_strings(int lib, ERR_STRING_DATA *str)
Expand All @@ -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)
Expand Down
70 changes: 37 additions & 33 deletions crypto/err/err_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Loading

0 comments on commit 69588ed

Please sign in to comment.