summaryrefslogtreecommitdiffstats
path: root/src/crypto/ex_data.c
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2015-09-25 02:36:32 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-09-25 02:36:32 +0000
commitd947d006e7a7ebcfdfe642e686250caf2028c2c1 (patch)
treedd743d9d64af3145fe96b8d5fc2f3427544794bd /src/crypto/ex_data.c
parent00bc53f6f4436972b7a8dcf2c1e5fd0ad7515872 (diff)
parentb8494591d1b1a143f3b192d845c238bbf3bc629d (diff)
downloadexternal_boringssl-d947d006e7a7ebcfdfe642e686250caf2028c2c1.zip
external_boringssl-d947d006e7a7ebcfdfe642e686250caf2028c2c1.tar.gz
external_boringssl-d947d006e7a7ebcfdfe642e686250caf2028c2c1.tar.bz2
am b8494591: Revert "Revert "external/boringssl: sync with upstream.""
* commit 'b8494591d1b1a143f3b192d845c238bbf3bc629d': Revert "Revert "external/boringssl: sync with upstream.""
Diffstat (limited to 'src/crypto/ex_data.c')
-rw-r--r--src/crypto/ex_data.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/crypto/ex_data.c b/src/crypto/ex_data.c
index 10fefc8..f562f17 100644
--- a/src/crypto/ex_data.c
+++ b/src/crypto/ex_data.c
@@ -138,7 +138,7 @@ int CRYPTO_get_ex_new_index(CRYPTO_EX_DATA_CLASS *ex_data_class, int *out_index,
funcs = OPENSSL_malloc(sizeof(CRYPTO_EX_DATA_FUNCS));
if (funcs == NULL) {
- OPENSSL_PUT_ERROR(CRYPTO, CRYPTO_get_ex_new_index, ERR_R_MALLOC_FAILURE);
+ OPENSSL_PUT_ERROR(CRYPTO, ERR_R_MALLOC_FAILURE);
return 0;
}
@@ -156,12 +156,13 @@ int CRYPTO_get_ex_new_index(CRYPTO_EX_DATA_CLASS *ex_data_class, int *out_index,
if (ex_data_class->meth == NULL ||
!sk_CRYPTO_EX_DATA_FUNCS_push(ex_data_class->meth, funcs)) {
- OPENSSL_PUT_ERROR(CRYPTO, CRYPTO_get_ex_new_index, ERR_R_MALLOC_FAILURE);
+ OPENSSL_PUT_ERROR(CRYPTO, ERR_R_MALLOC_FAILURE);
OPENSSL_free(funcs);
goto err;
}
- *out_index = sk_CRYPTO_EX_DATA_FUNCS_num(ex_data_class->meth) - 1;
+ *out_index = sk_CRYPTO_EX_DATA_FUNCS_num(ex_data_class->meth) - 1 +
+ ex_data_class->num_reserved;
ret = 1;
err:
@@ -175,7 +176,7 @@ int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int index, void *val) {
if (ad->sk == NULL) {
ad->sk = sk_void_new_null();
if (ad->sk == NULL) {
- OPENSSL_PUT_ERROR(CRYPTO, CRYPTO_set_ex_data, ERR_R_MALLOC_FAILURE);
+ OPENSSL_PUT_ERROR(CRYPTO, ERR_R_MALLOC_FAILURE);
return 0;
}
}
@@ -185,7 +186,7 @@ int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int index, void *val) {
/* Add NULL values until the stack is long enough. */
for (i = n; i <= index; i++) {
if (!sk_void_push(ad->sk, NULL)) {
- OPENSSL_PUT_ERROR(CRYPTO, CRYPTO_set_ex_data, ERR_R_MALLOC_FAILURE);
+ OPENSSL_PUT_ERROR(CRYPTO, ERR_R_MALLOC_FAILURE);
return 0;
}
}
@@ -222,7 +223,7 @@ static int get_func_pointers(STACK_OF(CRYPTO_EX_DATA_FUNCS) **out,
CRYPTO_STATIC_MUTEX_unlock(&ex_data_class->lock);
if (n > 0 && *out == NULL) {
- OPENSSL_PUT_ERROR(CRYPTO, get_func_pointers, ERR_R_MALLOC_FAILURE);
+ OPENSSL_PUT_ERROR(CRYPTO, ERR_R_MALLOC_FAILURE);
return 0;
}
@@ -244,8 +245,8 @@ int CRYPTO_new_ex_data(CRYPTO_EX_DATA_CLASS *ex_data_class, void *obj,
CRYPTO_EX_DATA_FUNCS *func_pointer =
sk_CRYPTO_EX_DATA_FUNCS_value(func_pointers, i);
if (func_pointer->new_func) {
- func_pointer->new_func(obj, NULL, ad, i, func_pointer->argl,
- func_pointer->argp);
+ func_pointer->new_func(obj, NULL, ad, i + ex_data_class->num_reserved,
+ func_pointer->argl, func_pointer->argp);
}
}
@@ -272,12 +273,12 @@ int CRYPTO_dup_ex_data(CRYPTO_EX_DATA_CLASS *ex_data_class, CRYPTO_EX_DATA *to,
for (i = 0; i < sk_CRYPTO_EX_DATA_FUNCS_num(func_pointers); i++) {
CRYPTO_EX_DATA_FUNCS *func_pointer =
sk_CRYPTO_EX_DATA_FUNCS_value(func_pointers, i);
- void *ptr = CRYPTO_get_ex_data(from, i);
+ void *ptr = CRYPTO_get_ex_data(from, i + ex_data_class->num_reserved);
if (func_pointer->dup_func) {
- func_pointer->dup_func(to, from, &ptr, i, func_pointer->argl,
- func_pointer->argp);
+ func_pointer->dup_func(to, from, &ptr, i + ex_data_class->num_reserved,
+ func_pointer->argl, func_pointer->argp);
}
- CRYPTO_set_ex_data(to, i, ptr);
+ CRYPTO_set_ex_data(to, i + ex_data_class->num_reserved, ptr);
}
sk_CRYPTO_EX_DATA_FUNCS_free(func_pointers);
@@ -298,9 +299,9 @@ void CRYPTO_free_ex_data(CRYPTO_EX_DATA_CLASS *ex_data_class, void *obj,
CRYPTO_EX_DATA_FUNCS *func_pointer =
sk_CRYPTO_EX_DATA_FUNCS_value(func_pointers, i);
if (func_pointer->free_func) {
- void *ptr = CRYPTO_get_ex_data(ad, i);
- func_pointer->free_func(obj, ptr, ad, i, func_pointer->argl,
- func_pointer->argp);
+ void *ptr = CRYPTO_get_ex_data(ad, i + ex_data_class->num_reserved);
+ func_pointer->free_func(obj, ptr, ad, i + ex_data_class->num_reserved,
+ func_pointer->argl, func_pointer->argp);
}
}