Add some error messages for malloc fails
Reviewed-by: Richard Levitte <levitte@openssl.org>
This commit is contained in:
parent
6ef020c988
commit
569d064609
12 changed files with 47 additions and 11 deletions
|
@ -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"},
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"},
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"},
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue