diff options
author | Geoff Thorpe <geoff@openssl.org> | 2001-08-12 16:52:00 +0000 |
---|---|---|
committer | Geoff Thorpe <geoff@openssl.org> | 2001-08-12 16:52:00 +0000 |
commit | b7727ee616a3351a001497dda077ec63330861db (patch) | |
tree | cfb5ada448b2a405e2b7b3967a48ba61f690d9aa /crypto | |
parent | f0446ca8d746ff138a892588e33597411f59f5fa (diff) |
The indexes returned by ***_get_ex_new_index() functions are used when
setting stack (actually, array) values in ex_data. So only increment the
global counters if the underlying CRYPTO_get_ex_new_index() call succeeds.
This change doesn't make "ex_data" right (see the comment at the head of
ex_data.c to know why), but at least makes the source code marginally less
frustrating.
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/asn1/x_x509.c | 7 | ||||
-rw-r--r-- | crypto/bio/bio_lib.c | 7 | ||||
-rw-r--r-- | crypto/dh/dh_lib.c | 7 | ||||
-rw-r--r-- | crypto/dsa/dsa_lib.c | 7 | ||||
-rw-r--r-- | crypto/rsa/rsa_lib.c | 7 | ||||
-rw-r--r-- | crypto/ui/ui_lib.c | 7 | ||||
-rw-r--r-- | crypto/x509/x509_vfy.c | 8 |
7 files changed, 28 insertions, 22 deletions
diff --git a/crypto/asn1/x_x509.c b/crypto/asn1/x_x509.c index 6a2adfc658..b0d859d38b 100644 --- a/crypto/asn1/x_x509.c +++ b/crypto/asn1/x_x509.c @@ -142,9 +142,10 @@ ASN1_METHOD *X509_asn1_meth(void) int X509_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) { - x509_meth_num++; - return(CRYPTO_get_ex_new_index(x509_meth_num-1, - &x509_meth,argl,argp,new_func,dup_func,free_func)); + if(CRYPTO_get_ex_new_index(x509_meth_num, &x509_meth, argl, argp, + new_func, dup_func, free_func) < 0) + return -1; + return (x509_meth_num++); } int X509_set_ex_data(X509 *r, int idx, void *arg) diff --git a/crypto/bio/bio_lib.c b/crypto/bio/bio_lib.c index 381afc9b8e..dcf033890d 100644 --- a/crypto/bio/bio_lib.c +++ b/crypto/bio/bio_lib.c @@ -512,9 +512,10 @@ void BIO_copy_next_retry(BIO *b) int BIO_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) { - bio_meth_num++; - return(CRYPTO_get_ex_new_index(bio_meth_num-1,&bio_meth, - argl,argp,new_func,dup_func,free_func)); + if(CRYPTO_get_ex_new_index(bio_meth_num, &bio_meth, argl, argp, + new_func, dup_func, free_func) < 0) + return -1; + return (bio_meth_num++); } int BIO_set_ex_data(BIO *bio, int idx, void *data) diff --git a/crypto/dh/dh_lib.c b/crypto/dh/dh_lib.c index dcd93c19a9..7a6e620715 100644 --- a/crypto/dh/dh_lib.c +++ b/crypto/dh/dh_lib.c @@ -222,9 +222,10 @@ void DH_free(DH *r) int DH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) { - dh_meth_num++; - return(CRYPTO_get_ex_new_index(dh_meth_num-1, - &dh_meth,argl,argp,new_func,dup_func,free_func)); + if(CRYPTO_get_ex_new_index(dh_meth_num, &dh_meth, argl, argp, + new_func, dup_func, free_func) < 0) + return -1; + return (dh_meth_num++); } int DH_set_ex_data(DH *d, int idx, void *arg) diff --git a/crypto/dsa/dsa_lib.c b/crypto/dsa/dsa_lib.c index 607f84e45b..5855568741 100644 --- a/crypto/dsa/dsa_lib.c +++ b/crypto/dsa/dsa_lib.c @@ -250,9 +250,10 @@ int DSA_size(const DSA *r) int DSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) { - dsa_meth_num++; - return(CRYPTO_get_ex_new_index(dsa_meth_num-1, - &dsa_meth,argl,argp,new_func,dup_func,free_func)); + if(CRYPTO_get_ex_new_index(dsa_meth_num, &dsa_meth, argl, argp, + new_func, dup_func, free_func) < 0) + return -1; + return (dsa_meth_num++); } int DSA_set_ex_data(DSA *d, int idx, void *arg) diff --git a/crypto/rsa/rsa_lib.c b/crypto/rsa/rsa_lib.c index 315671a60e..4fd919808c 100644 --- a/crypto/rsa/rsa_lib.c +++ b/crypto/rsa/rsa_lib.c @@ -251,9 +251,10 @@ void RSA_free(RSA *r) int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) { - rsa_meth_num++; - return(CRYPTO_get_ex_new_index(rsa_meth_num-1, - &rsa_meth,argl,argp,new_func,dup_func,free_func)); + if(CRYPTO_get_ex_new_index(rsa_meth_num, &rsa_meth, argl, argp, + new_func, dup_func, free_func) < 0) + return -1; + return (rsa_meth_num++); } int RSA_set_ex_data(RSA *r, int idx, void *arg) diff --git a/crypto/ui/ui_lib.c b/crypto/ui/ui_lib.c index 00abeb0e55..c526426f8b 100644 --- a/crypto/ui/ui_lib.c +++ b/crypto/ui/ui_lib.c @@ -574,9 +574,10 @@ int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f)()) int UI_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func) { - ui_meth_num++; - return(CRYPTO_get_ex_new_index(ui_meth_num-1, - &ui_meth,argl,argp,new_func,dup_func,free_func)); + if(CRYPTO_get_ex_new_index(ui_meth_num, &ui_meth, argl, argp, + new_func, dup_func, free_func) < 0) + return -1; + return (ui_meth_num++); } int UI_set_ex_data(UI *r, int idx, void *arg) diff --git a/crypto/x509/x509_vfy.c b/crypto/x509/x509_vfy.c index 0b9ae12a6f..4c3aae73a9 100644 --- a/crypto/x509/x509_vfy.c +++ b/crypto/x509/x509_vfy.c @@ -895,10 +895,10 @@ int X509_STORE_CTX_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_fu * That function uses locking, so we don't (usually) * have to worry about locking here. For the whole cruel * truth, see crypto/ex_data.c */ - x509_store_ctx_num++; - return CRYPTO_get_ex_new_index(x509_store_ctx_num-1, - &x509_store_ctx_method, - argl,argp,new_func,dup_func,free_func); + if(CRYPTO_get_ex_new_index(x509_store_ctx_num, &x509_store_ctx_method, + argl, argp, new_func, dup_func, free_func) < 0) + return -1; + return (x509_store_ctx_num++); } int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data) |