diff options
author | Matt Caswell <matt@openssl.org> | 2016-05-04 11:28:38 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-05-18 10:47:15 +0100 |
commit | 6ef020c988bb508842dfcd517a4b41cae214f641 (patch) | |
tree | c7cbc8c5fc0456b157c02c0a97fae580dab81b15 /crypto/dsa/dsa_meth.c | |
parent | 24854e0117000b81319665154c93e15743bf7de6 (diff) |
Better checks for malloc failure in various METHOD functions
A number of the METHOD functions weren't properly handling malloc failures.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/dsa/dsa_meth.c')
-rw-r--r-- | crypto/dsa/dsa_meth.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/crypto/dsa/dsa_meth.c b/crypto/dsa/dsa_meth.c index 4379d9d5d1..57bc9f0971 100644 --- a/crypto/dsa/dsa_meth.c +++ b/crypto/dsa/dsa_meth.c @@ -24,6 +24,10 @@ DSA_METHOD *DSA_meth_new(const char *name, int flags) if (dsam != NULL) { dsam->name = OPENSSL_strdup(name); + if (dsam->name == NULL) { + OPENSSL_free(dsam); + return NULL; + } dsam->flags = flags; } @@ -48,6 +52,10 @@ DSA_METHOD *DSA_meth_dup(const DSA_METHOD *dsam) if (ret != NULL) { memcpy(ret, dsam, sizeof(*dsam)); ret->name = OPENSSL_strdup(dsam->name); + if (ret->name == NULL) { + OPENSSL_free(ret); + return NULL; + } } return ret; @@ -60,10 +68,16 @@ const char *DSA_meth_get0_name(const DSA_METHOD *dsam) int DSA_meth_set1_name(DSA_METHOD *dsam, const char *name) { + char *tmpname; + + tmpname = OPENSSL_strdup(name); + if (tmpname == NULL) + return 0; + OPENSSL_free(dsam->name); - dsam->name = OPENSSL_strdup(name); + dsam->name = tmpname; - return dsam->name != NULL; + return 1; } int DSA_meth_get_flags(DSA_METHOD *dsam) |