Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@chromium.org>2015-06-30 06:36:17 +0300
committerAdam Langley <agl@google.com>2015-07-20 19:56:34 +0300
commitaa58513f404f1d939fd2f6081e24c4c6b0027cb0 (patch)
tree5036d9ba577f4825420240e1bdd6864857875394 /crypto/ex_data.c
parent31ac9aae51b8ce69afd318149d8fea27cd16955c (diff)
Reserve ex_data index zero for app_data.
In the ancient times, before ex_data and OpenSSL, SSLeay supported a single app_data slot in various types. Later app_data begat ex_data, and app_data was replaced by compatibility macros to ex_data index zero. Today, app_data is still in use, but ex_data never reserved index zero for app_data. This causes some danger where, if the first ex_data registration did not use NULL callbacks, the registration's callbacks would collide with app_data. Instead, add an option to the types with app_data to reserve index zero. Also switch SSL_get_ex_data_X509_STORE_CTX_idx to always return zero rather than allocate a new one. It used to be that you used X509_STORE_CTX_get_app_data. I only found one consumer that we probably don't care about, but, to be safe and since it's easy, go with the conservative option. (Although SSL_get_ex_data_X509_STORE_CTX_idx wasn't guaranteed to alias app_data, in practice it always did. No consumer ever calls X509_STORE_CTX_get_ex_new_index.) Change-Id: Ie75b279d60aefd003ffef103f99021c5d696a5e9 Reviewed-on: https://boringssl-review.googlesource.com/5313 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/ex_data.c')
-rw-r--r--crypto/ex_data.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/crypto/ex_data.c b/crypto/ex_data.c
index b2726509..f562f17b 100644
--- a/crypto/ex_data.c
+++ b/crypto/ex_data.c
@@ -161,7 +161,8 @@ int CRYPTO_get_ex_new_index(CRYPTO_EX_DATA_CLASS *ex_data_class, int *out_index,
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:
@@ -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);
}
}