Update to OpenSSL 1.0.2.o
This commit is contained in:
@@ -331,7 +331,11 @@ static EX_CLASS_ITEM *def_get_class(int class_index)
|
||||
* from the insert will be NULL
|
||||
*/
|
||||
(void)lh_EX_CLASS_ITEM_insert(ex_data, gen);
|
||||
p = gen;
|
||||
p = lh_EX_CLASS_ITEM_retrieve(ex_data, &d);
|
||||
if (p != gen) {
|
||||
sk_CRYPTO_EX_DATA_FUNCS_free(gen->meth);
|
||||
OPENSSL_free(gen);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -455,7 +459,7 @@ static int int_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
|
||||
CRYPTO_EX_DATA *from)
|
||||
{
|
||||
int mx, j, i;
|
||||
char *ptr;
|
||||
void *ptr;
|
||||
CRYPTO_EX_DATA_FUNCS **storage = NULL;
|
||||
EX_CLASS_ITEM *item;
|
||||
if (!from->sk)
|
||||
@@ -469,6 +473,15 @@ static int int_dup_ex_data(int class_index, CRYPTO_EX_DATA *to,
|
||||
if (j < mx)
|
||||
mx = j;
|
||||
if (mx > 0) {
|
||||
/*
|
||||
* Make sure the ex_data stack is at least |mx| elements long to avoid
|
||||
* issues in the for loop that follows; so go get the |mx|'th element
|
||||
* (if it does not exist CRYPTO_get_ex_data() returns NULL), and assign
|
||||
* to itself. This is normally a no-op; but ensures the stack is the
|
||||
* proper size
|
||||
*/
|
||||
if (!CRYPTO_set_ex_data(to, mx - 1, CRYPTO_get_ex_data(to, mx - 1)))
|
||||
goto skip;
|
||||
storage = OPENSSL_malloc(mx * sizeof(CRYPTO_EX_DATA_FUNCS *));
|
||||
if (!storage)
|
||||
goto skip;
|
||||
@@ -499,11 +512,12 @@ static void int_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
|
||||
int mx, i;
|
||||
EX_CLASS_ITEM *item;
|
||||
void *ptr;
|
||||
CRYPTO_EX_DATA_FUNCS *f;
|
||||
CRYPTO_EX_DATA_FUNCS **storage = NULL;
|
||||
if (ex_data == NULL)
|
||||
return;
|
||||
goto err;
|
||||
if ((item = def_get_class(class_index)) == NULL)
|
||||
return;
|
||||
goto err;
|
||||
CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA);
|
||||
mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth);
|
||||
if (mx > 0) {
|
||||
@@ -515,23 +529,23 @@ static void int_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
|
||||
}
|
||||
skip:
|
||||
CRYPTO_r_unlock(CRYPTO_LOCK_EX_DATA);
|
||||
if ((mx > 0) && !storage) {
|
||||
CRYPTOerr(CRYPTO_F_INT_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_r_lock(CRYPTO_LOCK_EX_DATA);
|
||||
f = sk_CRYPTO_EX_DATA_FUNCS_value(item->meth, i);
|
||||
CRYPTO_r_unlock(CRYPTO_LOCK_EX_DATA);
|
||||
}
|
||||
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)
|
||||
OPENSSL_free(storage);
|
||||
if (ad->sk) {
|
||||
sk_void_free(ad->sk);
|
||||
ad->sk = NULL;
|
||||
}
|
||||
OPENSSL_free(storage);
|
||||
err:
|
||||
sk_void_free(ad->sk);
|
||||
ad->sk = NULL;
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user