diff options
author | Matt Caswell <matt@openssl.org> | 2016-05-17 15:08:43 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-05-18 10:47:15 +0100 |
commit | 569d0646096e6c7e07b9b89b04204eef934c3b69 (patch) | |
tree | 8e649d1b033ec73cb6134123aa0024daf2394387 | |
parent | 6ef020c988bb508842dfcd517a4b41cae214f641 (diff) |
Add some error messages for malloc fails
Reviewed-by: Richard Levitte <levitte@openssl.org>
-rw-r--r-- | crypto/dh/dh_err.c | 3 | ||||
-rw-r--r-- | crypto/dh/dh_meth.c | 7 | ||||
-rw-r--r-- | crypto/dsa/dsa_err.c | 3 | ||||
-rw-r--r-- | crypto/dsa/dsa_meth.c | 7 | ||||
-rw-r--r-- | crypto/rsa/rsa_err.c | 11 | ||||
-rw-r--r-- | crypto/rsa/rsa_meth.c | 7 | ||||
-rw-r--r-- | crypto/ui/ui_err.c | 1 | ||||
-rw-r--r-- | crypto/ui/ui_lib.c | 1 | ||||
-rw-r--r-- | include/openssl/dh.h | 3 | ||||
-rw-r--r-- | include/openssl/dsa.h | 3 | ||||
-rw-r--r-- | include/openssl/rsa.h | 11 | ||||
-rw-r--r-- | include/openssl/ui.h | 1 |
12 files changed, 47 insertions, 11 deletions
diff --git a/crypto/dh/dh_err.c b/crypto/dh/dh_err.c index a1bada9e98..e1e5b49ee0 100644 --- a/crypto/dh/dh_err.c +++ b/crypto/dh/dh_err.c @@ -30,6 +30,9 @@ static ERR_STRING_DATA DH_str_functs[] = { {ERR_FUNC(DH_F_DH_CMS_DECRYPT), "dh_cms_decrypt"}, {ERR_FUNC(DH_F_DH_CMS_SET_PEERKEY), "dh_cms_set_peerkey"}, {ERR_FUNC(DH_F_DH_CMS_SET_SHARED_INFO), "dh_cms_set_shared_info"}, + {ERR_FUNC(DH_F_DH_METH_DUP), "DH_meth_dup"}, + {ERR_FUNC(DH_F_DH_METH_NEW), "DH_meth_new"}, + {ERR_FUNC(DH_F_DH_METH_SET1_NAME), "DH_meth_set1_name"}, {ERR_FUNC(DH_F_DH_NEW_METHOD), "DH_new_method"}, {ERR_FUNC(DH_F_DH_PARAM_DECODE), "dh_param_decode"}, {ERR_FUNC(DH_F_DH_PRIV_DECODE), "dh_priv_decode"}, diff --git a/crypto/dh/dh_meth.c b/crypto/dh/dh_meth.c index dbc03143fb..afd47aba8a 100644 --- a/crypto/dh/dh_meth.c +++ b/crypto/dh/dh_meth.c @@ -9,6 +9,7 @@ #include "dh_locl.h" #include <string.h> +#include <openssl/err.h> DH_METHOD *DH_meth_new(const char *name, int flags) { @@ -18,6 +19,7 @@ DH_METHOD *DH_meth_new(const char *name, int flags) dhm->name = OPENSSL_strdup(name); if (dhm->name == NULL) { OPENSSL_free(dhm); + DHerr(DH_F_DH_METH_NEW, ERR_R_MALLOC_FAILURE); return NULL; } dhm->flags = flags; @@ -46,6 +48,7 @@ DH_METHOD *DH_meth_dup(const DH_METHOD *dhm) ret->name = OPENSSL_strdup(dhm->name); if (ret->name == NULL) { OPENSSL_free(ret); + DHerr(DH_F_DH_METH_DUP, ERR_R_MALLOC_FAILURE); return NULL; } } @@ -63,8 +66,10 @@ int DH_meth_set1_name(DH_METHOD *dhm, const char *name) char *tmpname; tmpname = OPENSSL_strdup(name); - if (tmpname == NULL) + if (tmpname == NULL) { + DHerr(DH_F_DH_METH_SET1_NAME, ERR_R_MALLOC_FAILURE); return 0; + } OPENSSL_free(dhm->name); dhm->name = tmpname; diff --git a/crypto/dsa/dsa_err.c b/crypto/dsa/dsa_err.c index 9c5ae981b7..038a031d09 100644 --- a/crypto/dsa/dsa_err.c +++ b/crypto/dsa/dsa_err.c @@ -33,6 +33,9 @@ static ERR_STRING_DATA DSA_str_functs[] = { {ERR_FUNC(DSA_F_DSA_BUILTIN_PARAMGEN2), "dsa_builtin_paramgen2"}, {ERR_FUNC(DSA_F_DSA_DO_SIGN), "DSA_do_sign"}, {ERR_FUNC(DSA_F_DSA_DO_VERIFY), "DSA_do_verify"}, + {ERR_FUNC(DSA_F_DSA_METH_DUP), "DSA_meth_dup"}, + {ERR_FUNC(DSA_F_DSA_METH_NEW), "DSA_meth_new"}, + {ERR_FUNC(DSA_F_DSA_METH_SET1_NAME), "DSA_meth_set1_name"}, {ERR_FUNC(DSA_F_DSA_NEW_METHOD), "DSA_new_method"}, {ERR_FUNC(DSA_F_DSA_PARAM_DECODE), "dsa_param_decode"}, {ERR_FUNC(DSA_F_DSA_PRINT_FP), "DSA_print_fp"}, diff --git a/crypto/dsa/dsa_meth.c b/crypto/dsa/dsa_meth.c index 57bc9f0971..5ce93396cf 100644 --- a/crypto/dsa/dsa_meth.c +++ b/crypto/dsa/dsa_meth.c @@ -17,6 +17,7 @@ #include "dsa_locl.h" #include <string.h> +#include <openssl/err.h> DSA_METHOD *DSA_meth_new(const char *name, int flags) { @@ -26,6 +27,7 @@ DSA_METHOD *DSA_meth_new(const char *name, int flags) dsam->name = OPENSSL_strdup(name); if (dsam->name == NULL) { OPENSSL_free(dsam); + DSAerr(DSA_F_DSA_METH_NEW, ERR_R_MALLOC_FAILURE); return NULL; } dsam->flags = flags; @@ -54,6 +56,7 @@ DSA_METHOD *DSA_meth_dup(const DSA_METHOD *dsam) ret->name = OPENSSL_strdup(dsam->name); if (ret->name == NULL) { OPENSSL_free(ret); + DSAerr(DSA_F_DSA_METH_DUP, ERR_R_MALLOC_FAILURE); return NULL; } } @@ -71,8 +74,10 @@ int DSA_meth_set1_name(DSA_METHOD *dsam, const char *name) char *tmpname; tmpname = OPENSSL_strdup(name); - if (tmpname == NULL) + if (tmpname == NULL) { + DSAerr(DSA_F_DSA_METH_SET1_NAME, ERR_R_MALLOC_FAILURE); return 0; + } OPENSSL_free(dsam->name); dsam->name = tmpname; diff --git a/crypto/rsa/rsa_err.c b/crypto/rsa/rsa_err.c index d23aa3d530..54aea982d7 100644 --- a/crypto/rsa/rsa_err.c +++ b/crypto/rsa/rsa_err.c @@ -41,13 +41,12 @@ static ERR_STRING_DATA RSA_str_functs[] = { {ERR_FUNC(RSA_F_RSA_CHECK_KEY), "RSA_check_key"}, {ERR_FUNC(RSA_F_RSA_CHECK_KEY_EX), "RSA_check_key_ex"}, {ERR_FUNC(RSA_F_RSA_CMS_DECRYPT), "rsa_cms_decrypt"}, - {ERR_FUNC(RSA_F_RSA_OSSL_PRIVATE_DECRYPT), "rsa_ossl_private_decrypt"}, - {ERR_FUNC(RSA_F_RSA_OSSL_PRIVATE_ENCRYPT), "rsa_ossl_private_encrypt"}, - {ERR_FUNC(RSA_F_RSA_OSSL_PUBLIC_DECRYPT), "rsa_ossl_public_decrypt"}, - {ERR_FUNC(RSA_F_RSA_OSSL_PUBLIC_ENCRYPT), "rsa_ossl_public_encrypt"}, {ERR_FUNC(RSA_F_RSA_GENERATE_KEY), "RSA_generate_key"}, {ERR_FUNC(RSA_F_RSA_ITEM_VERIFY), "rsa_item_verify"}, {ERR_FUNC(RSA_F_RSA_MEMORY_LOCK), "RSA_memory_lock"}, + {ERR_FUNC(RSA_F_RSA_METH_DUP), "RSA_meth_dup"}, + {ERR_FUNC(RSA_F_RSA_METH_NEW), "RSA_meth_new"}, + {ERR_FUNC(RSA_F_RSA_METH_SET1_NAME), "RSA_meth_set1_name"}, {ERR_FUNC(RSA_F_RSA_MGF1_TO_MD), "rsa_mgf1_to_md"}, {ERR_FUNC(RSA_F_RSA_NEW_METHOD), "RSA_new_method"}, {ERR_FUNC(RSA_F_RSA_NULL), "RSA_NULL"}, @@ -57,6 +56,10 @@ static ERR_STRING_DATA RSA_str_functs[] = { {ERR_FUNC(RSA_F_RSA_NULL_PUBLIC_DECRYPT), "RSA_null_public_decrypt"}, {ERR_FUNC(RSA_F_RSA_NULL_PUBLIC_ENCRYPT), "RSA_null_public_encrypt"}, {ERR_FUNC(RSA_F_RSA_OAEP_TO_CTX), "RSA_OAEP_TO_CTX"}, + {ERR_FUNC(RSA_F_RSA_OSSL_PRIVATE_DECRYPT), "rsa_ossl_private_decrypt"}, + {ERR_FUNC(RSA_F_RSA_OSSL_PRIVATE_ENCRYPT), "rsa_ossl_private_encrypt"}, + {ERR_FUNC(RSA_F_RSA_OSSL_PUBLIC_DECRYPT), "rsa_ossl_public_decrypt"}, + {ERR_FUNC(RSA_F_RSA_OSSL_PUBLIC_ENCRYPT), "rsa_ossl_public_encrypt"}, {ERR_FUNC(RSA_F_RSA_PADDING_ADD_NONE), "RSA_padding_add_none"}, {ERR_FUNC(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP), "RSA_padding_add_PKCS1_OAEP"}, {ERR_FUNC(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP_MGF1), diff --git a/crypto/rsa/rsa_meth.c b/crypto/rsa/rsa_meth.c index 731164c561..bce5ee8ba9 100644 --- a/crypto/rsa/rsa_meth.c +++ b/crypto/rsa/rsa_meth.c @@ -9,6 +9,7 @@ #include <string.h> #include "rsa_locl.h" +#include <openssl/err.h> RSA_METHOD *RSA_meth_new(const char *name, int flags) { @@ -18,6 +19,7 @@ RSA_METHOD *RSA_meth_new(const char *name, int flags) meth->name = OPENSSL_strdup(name); if (meth->name == NULL) { OPENSSL_free(meth); + RSAerr(RSA_F_RSA_METH_NEW, ERR_R_MALLOC_FAILURE); return NULL; } meth->flags = flags; @@ -46,6 +48,7 @@ RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth) ret->name = OPENSSL_strdup(meth->name); if (ret->name == NULL) { OPENSSL_free(ret); + RSAerr(RSA_F_RSA_METH_DUP, ERR_R_MALLOC_FAILURE); return NULL; } } @@ -63,8 +66,10 @@ int RSA_meth_set1_name(RSA_METHOD *meth, const char *name) char *tmpname; tmpname = OPENSSL_strdup(name); - if (tmpname == NULL) + if (tmpname == NULL) { + RSAerr(RSA_F_RSA_METH_SET1_NAME, ERR_R_MALLOC_FAILURE); return 0; + } OPENSSL_free(meth->name); meth->name = tmpname; diff --git a/crypto/ui/ui_err.c b/crypto/ui/ui_err.c index e97dd06533..fbcb886180 100644 --- a/crypto/ui/ui_err.c +++ b/crypto/ui/ui_err.c @@ -21,6 +21,7 @@ static ERR_STRING_DATA UI_str_functs[] = { {ERR_FUNC(UI_F_GENERAL_ALLOCATE_BOOLEAN), "general_allocate_boolean"}, {ERR_FUNC(UI_F_GENERAL_ALLOCATE_PROMPT), "general_allocate_prompt"}, {ERR_FUNC(UI_F_GENERAL_ALLOCATE_STRING), "GENERAL_ALLOCATE_STRING"}, + {ERR_FUNC(UI_F_UI_CREATE_METHOD), "UI_create_method"}, {ERR_FUNC(UI_F_UI_CTRL), "UI_ctrl"}, {ERR_FUNC(UI_F_UI_DUP_ERROR_STRING), "UI_dup_error_string"}, {ERR_FUNC(UI_F_UI_DUP_INFO_STRING), "UI_dup_info_string"}, diff --git a/crypto/ui/ui_lib.c b/crypto/ui/ui_lib.c index 3d0df5140d..1213892ad5 100644 --- a/crypto/ui/ui_lib.c +++ b/crypto/ui/ui_lib.c @@ -540,6 +540,7 @@ UI_METHOD *UI_create_method(char *name) ui_method->name = OPENSSL_strdup(name); if (ui_method->name == NULL) { OPENSSL_free(ui_method); + UIerr(UI_F_UI_CREATE_METHOD, ERR_R_MALLOC_FAILURE); return NULL; } } diff --git a/include/openssl/dh.h b/include/openssl/dh.h index 0d6870b7f2..852aeaf757 100644 --- a/include/openssl/dh.h +++ b/include/openssl/dh.h @@ -298,6 +298,9 @@ void ERR_load_DH_strings(void); # define DH_F_DH_CMS_DECRYPT 114 # define DH_F_DH_CMS_SET_PEERKEY 115 # define DH_F_DH_CMS_SET_SHARED_INFO 116 +# define DH_F_DH_METH_DUP 117 +# define DH_F_DH_METH_NEW 118 +# define DH_F_DH_METH_SET1_NAME 119 # define DH_F_DH_NEW_METHOD 105 # define DH_F_DH_PARAM_DECODE 107 # define DH_F_DH_PRIV_DECODE 110 diff --git a/include/openssl/dsa.h b/include/openssl/dsa.h index c8751d0ff4..f9034d91f0 100644 --- a/include/openssl/dsa.h +++ b/include/openssl/dsa.h @@ -242,6 +242,9 @@ void ERR_load_DSA_strings(void); # define DSA_F_DSA_BUILTIN_PARAMGEN2 126 # define DSA_F_DSA_DO_SIGN 112 # define DSA_F_DSA_DO_VERIFY 113 +# define DSA_F_DSA_METH_DUP 127 +# define DSA_F_DSA_METH_NEW 128 +# define DSA_F_DSA_METH_SET1_NAME 129 # define DSA_F_DSA_NEW_METHOD 103 # define DSA_F_DSA_PARAM_DECODE 119 # define DSA_F_DSA_PRINT_FP 105 diff --git a/include/openssl/rsa.h b/include/openssl/rsa.h index 7ed0d24338..1f14fd730c 100644 --- a/include/openssl/rsa.h +++ b/include/openssl/rsa.h @@ -484,13 +484,12 @@ void ERR_load_RSA_strings(void); # define RSA_F_RSA_CHECK_KEY 123 # define RSA_F_RSA_CHECK_KEY_EX 160 # define RSA_F_RSA_CMS_DECRYPT 159 -# define RSA_F_RSA_OSSL_PRIVATE_DECRYPT 101 -# define RSA_F_RSA_OSSL_PRIVATE_ENCRYPT 102 -# define RSA_F_RSA_OSSL_PUBLIC_DECRYPT 103 -# define RSA_F_RSA_OSSL_PUBLIC_ENCRYPT 104 # define RSA_F_RSA_GENERATE_KEY 105 # define RSA_F_RSA_ITEM_VERIFY 148 # define RSA_F_RSA_MEMORY_LOCK 130 +# define RSA_F_RSA_METH_DUP 161 +# define RSA_F_RSA_METH_NEW 162 +# define RSA_F_RSA_METH_SET1_NAME 163 # define RSA_F_RSA_MGF1_TO_MD 157 # define RSA_F_RSA_NEW_METHOD 106 # define RSA_F_RSA_NULL 124 @@ -500,6 +499,10 @@ void ERR_load_RSA_strings(void); # define RSA_F_RSA_NULL_PUBLIC_DECRYPT 134 # define RSA_F_RSA_NULL_PUBLIC_ENCRYPT 135 # define RSA_F_RSA_OAEP_TO_CTX 158 +# define RSA_F_RSA_OSSL_PRIVATE_DECRYPT 101 +# define RSA_F_RSA_OSSL_PRIVATE_ENCRYPT 102 +# define RSA_F_RSA_OSSL_PUBLIC_DECRYPT 103 +# define RSA_F_RSA_OSSL_PUBLIC_ENCRYPT 104 # define RSA_F_RSA_PADDING_ADD_NONE 107 # define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP 121 # define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP_MGF1 154 diff --git a/include/openssl/ui.h b/include/openssl/ui.h index 482c3fbcdf..c6c20b5211 100644 --- a/include/openssl/ui.h +++ b/include/openssl/ui.h @@ -341,6 +341,7 @@ void ERR_load_UI_strings(void); # define UI_F_GENERAL_ALLOCATE_BOOLEAN 108 # define UI_F_GENERAL_ALLOCATE_PROMPT 109 # define UI_F_GENERAL_ALLOCATE_STRING 100 +# define UI_F_UI_CREATE_METHOD 112 # define UI_F_UI_CTRL 111 # define UI_F_UI_DUP_ERROR_STRING 101 # define UI_F_UI_DUP_INFO_STRING 102 |