diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2017-02-01 18:29:47 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2017-02-03 20:39:52 +0100 |
commit | 83b4049ab75e9da1815e9c854a9297bca3d4af6b (patch) | |
tree | 35e657e8100ec911f851e3ecb09daf0093a0c173 /crypto/ex_data.c | |
parent | 21f198ec4874f7e2780a0afd0bdd3c038f69ed11 (diff) |
Combined patch against master branch for the following issues:
Fixed a memory leak in ASN1_digest and ASN1_item_digest.
Reworked error handling in asn1_item_embed_new.
Fixed error handling in int_ctx_new and EVP_PKEY_CTX_dup.
Fixed a memory leak in CRYPTO_free_ex_data.
Reworked error handing in x509_name_ex_d2i, x509_name_encode and x509_name_canon.
Check for null pointer in tls_process_cert_verify.
Fixes #2103 #2104 #2105 #2109 #2111 #2115
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2342)
Diffstat (limited to 'crypto/ex_data.c')
-rw-r--r-- | crypto/ex_data.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/crypto/ex_data.c b/crypto/ex_data.c index bb1af0b3b1..84b65551c6 100644 --- a/crypto/ex_data.c +++ b/crypto/ex_data.c @@ -307,11 +307,12 @@ void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad) int mx, i; EX_CALLBACKS *ip; void *ptr; + EX_CALLBACK *f; EX_CALLBACK *stack[10]; EX_CALLBACK **storage = NULL; if ((ip = get_and_lock(class_index)) == NULL) - return; + goto err; mx = sk_EX_CALLBACK_num(ip->meth); if (mx > 0) { @@ -325,20 +326,23 @@ void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad) } CRYPTO_THREAD_unlock(ex_data_lock); - if (mx > 0 && storage == NULL) { - CRYPTOerr(CRYPTO_F_CRYPTO_FREE_EX_DATA, ERR_R_MALLOC_FAILURE); - return; - } for (i = 0; i < mx; i++) { - if (storage[i] && storage[i]->free_func) { + if (storage != NULL) + f = storage[i]; + else { + CRYPTO_THREAD_write_lock(ex_data_lock); + f = sk_EX_CALLBACK_value(ip->meth, i); + CRYPTO_THREAD_unlock(ex_data_lock); + } + if (f != NULL && f->free_func != NULL) { ptr = CRYPTO_get_ex_data(ad, i); - storage[i]->free_func(obj, ptr, ad, i, - storage[i]->argl, storage[i]->argp); + f->free_func(obj, ptr, ad, i, f->argl, f->argp); } } if (storage != stack) OPENSSL_free(storage); + err: sk_void_free(ad->sk); ad->sk = NULL; } |