diff options
author | FdaSilvaYY <fdasilvayy@gmail.com> | 2016-02-14 10:42:29 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-05-23 14:43:31 +0200 |
commit | e5a5e3f3db5832f7ba4eff8016bad00f37dada58 (patch) | |
tree | 455a6c449e51f7702f5a06fa8cfd817bbed018eb /crypto/engine | |
parent | Fix some malloc failure crashes on X509_STORE_CTX_set_ex_data (diff) | |
download | openssl-e5a5e3f3db5832f7ba4eff8016bad00f37dada58.tar.xz openssl-e5a5e3f3db5832f7ba4eff8016bad00f37dada58.zip |
Add checks on CRYPTO_set_ex_data return value
Fix possible leak in danetest.c
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'crypto/engine')
-rw-r--r-- | crypto/engine/eng_dyn.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/crypto/engine/eng_dyn.c b/crypto/engine/eng_dyn.c index af9942c082..718599f6d9 100644 --- a/crypto/engine/eng_dyn.c +++ b/crypto/engine/eng_dyn.c @@ -154,6 +154,7 @@ static void dynamic_data_ctx_free_func(void *parent, void *ptr, static int dynamic_set_data_ctx(ENGINE *e, dynamic_data_ctx **ctx) { dynamic_data_ctx *c = OPENSSL_zalloc(sizeof(*c)); + int ret = 1; if (c == NULL) { ENGINEerr(ENGINE_F_DYNAMIC_SET_DATA_CTX, ERR_R_MALLOC_FAILURE); @@ -173,9 +174,11 @@ static int dynamic_set_data_ctx(ENGINE *e, dynamic_data_ctx **ctx) dynamic_ex_data_idx)) == NULL) { /* Good, we're the first */ - ENGINE_set_ex_data(e, dynamic_ex_data_idx, c); - *ctx = c; - c = NULL; + ret = ENGINE_set_ex_data(e, dynamic_ex_data_idx, c); + if (ret) { + *ctx = c; + c = NULL; + } } CRYPTO_THREAD_unlock(global_engine_lock); /* @@ -185,7 +188,7 @@ static int dynamic_set_data_ctx(ENGINE *e, dynamic_data_ctx **ctx) if (c) sk_OPENSSL_STRING_free(c->dirs); OPENSSL_free(c); - return 1; + return ret; } /* |