X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fex_data.c;h=ff32ad5be6b35ed724b4ada6bff2c9e8b555d883;hp=a057dd3b686a9a086df55031cd7419d96e5507ce;hb=4dc719fc37cb2201c8e211c6a684d71477c20f50;hpb=dd9d233e2aa493fa1398b527afbf6aa5cdb23f23 diff --git a/crypto/ex_data.c b/crypto/ex_data.c index a057dd3b68..ff32ad5be6 100644 --- a/crypto/ex_data.c +++ b/crypto/ex_data.c @@ -1,4 +1,19 @@ /* crypto/ex_data.c */ + +/* + * This is not thread-safe, nor can it be changed to become thread-safe + * without changing various function prototypes and using a lot of locking. + * Luckily, it's not really used anywhere except in ssl_verify_cert_chain + * via SSL_get_ex_data_X509_STORE_CTX_idx (ssl/ssl_cert.c), + * where new_func, dup_func, and free_func all are 0, and in + * hwcrhk_init (crypto/engine/hw_ncipher.c), which is hopefully only + * ever used during program initialization. + * + * Any multi-threaded application crazy enough to use ex_data for its own + * purposes had better make sure that SSL_get_ex_data_X509_STORE_CTX_idx + * is called once before multiple threads are created. + */ + /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -77,7 +92,7 @@ int CRYPTO_get_ex_new_index(int idx, STACK_OF(CRYPTO_EX_DATA_FUNCS) **skp, long CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX,ERR_R_MALLOC_FAILURE); goto err; } - a=(CRYPTO_EX_DATA_FUNCS *)Malloc(sizeof(CRYPTO_EX_DATA_FUNCS)); + a=(CRYPTO_EX_DATA_FUNCS *)OPENSSL_malloc(sizeof(CRYPTO_EX_DATA_FUNCS)); if (a == NULL) { CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX,ERR_R_MALLOC_FAILURE); @@ -93,7 +108,7 @@ int CRYPTO_get_ex_new_index(int idx, STACK_OF(CRYPTO_EX_DATA_FUNCS) **skp, long if (!sk_CRYPTO_EX_DATA_FUNCS_push(*skp,NULL)) { CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX,ERR_R_MALLOC_FAILURE); - Free(a); + OPENSSL_free(a); goto err; } } @@ -101,7 +116,7 @@ int CRYPTO_get_ex_new_index(int idx, STACK_OF(CRYPTO_EX_DATA_FUNCS) **skp, long ret=idx; err: MemCheck_on(); - return(idx); + return(ret); } int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val) @@ -131,7 +146,7 @@ int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val) return(1); } -void *CRYPTO_get_ex_data(CRYPTO_EX_DATA *ad, int idx) +void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx) { if (ad->sk == NULL) return(0);