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 /crypto/rsa | |
parent | 6ef020c988bb508842dfcd517a4b41cae214f641 (diff) |
Add some error messages for malloc fails
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/rsa')
-rw-r--r-- | crypto/rsa/rsa_err.c | 11 | ||||
-rw-r--r-- | crypto/rsa/rsa_meth.c | 7 |
2 files changed, 13 insertions, 5 deletions
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; |