The indexes returned by ***_get_ex_new_index() functions are used when
authorGeoff Thorpe <geoff@openssl.org>
Sun, 12 Aug 2001 16:52:00 +0000 (16:52 +0000)
committerGeoff Thorpe <geoff@openssl.org>
Sun, 12 Aug 2001 16:52:00 +0000 (16:52 +0000)
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.

crypto/asn1/x_x509.c
crypto/bio/bio_lib.c
crypto/dh/dh_lib.c
crypto/dsa/dsa_lib.c
crypto/rsa/rsa_lib.c
crypto/ui/ui_lib.c
crypto/x509/x509_vfy.c
ssl/ssl_lib.c
ssl/ssl_sess.c

index 6a2adfc6582937150dda841378533e0a2e483edd..b0d859d38bad0e8a86a797fdb4895162b38e2343 100644 (file)
@@ -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)
index 381afc9b8e03a05d5e8b3459e5a3d9facc4b5055..dcf033890d7b03b05861780fb7cdd4d6b6bd7103 100644 (file)
@@ -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)
index dcd93c19a955bf44fab7e6d4eaa48fcab3ae42f0..7a6e6207153a786a65dc07f880f8b719b4bad1e8 100644 (file)
@@ -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)
index 607f84e45b9cd7e7585b65bb10e506d21f848856..5855568741a38640f897014c7b5759b978b4e1f8 100644 (file)
@@ -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)
index 315671a60e501fc6a001501c847ce45707d7d907..4fd919808c34ea68939cae8a443fab0369a3dc47 100644 (file)
@@ -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)
index 00abeb0e552db9213562b027e3c0cd47f0d9f288..c526426f8b2b73eac5aa88a7990d8d141a4ebd3c 100644 (file)
@@ -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)
index 0b9ae12a6f12a3bad3419d8ebe5823a4e7e0c119..4c3aae73a9a58b1223575ea9786b82cef933f5a6 100644 (file)
@@ -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)
index f4dfdbf250fcc70ee816ff90df76e506ece66865..df085e6a02136672330f2c20f3b0c55cd94dc507 100644 (file)
@@ -2051,9 +2051,10 @@ long SSL_get_verify_result(SSL *ssl)
 int SSL_get_ex_new_index(long argl,void *argp,CRYPTO_EX_new *new_func,
                         CRYPTO_EX_dup *dup_func,CRYPTO_EX_free *free_func)
        {
-       ssl_meth_num++;
-       return(CRYPTO_get_ex_new_index(ssl_meth_num-1,
-               &ssl_meth,argl,argp,new_func,dup_func,free_func));
+       if(CRYPTO_get_ex_new_index(ssl_meth_num, &ssl_meth, argl, argp,
+                               new_func, dup_func, free_func) < 0)
+               return -1;
+       return (ssl_meth_num++);
        }
 
 int SSL_set_ex_data(SSL *s,int idx,void *arg)
@@ -2069,9 +2070,10 @@ void *SSL_get_ex_data(SSL *s,int idx)
 int SSL_CTX_get_ex_new_index(long argl,void *argp,CRYPTO_EX_new *new_func,
                             CRYPTO_EX_dup *dup_func,CRYPTO_EX_free *free_func)
        {
-       ssl_ctx_meth_num++;
-       return(CRYPTO_get_ex_new_index(ssl_ctx_meth_num-1,
-               &ssl_ctx_meth,argl,argp,new_func,dup_func,free_func));
+       if(CRYPTO_get_ex_new_index(ssl_ctx_meth_num, &ssl_ctx_meth, argl, argp,
+                               new_func, dup_func, free_func) < 0)
+               return -1;
+       return (ssl_ctx_meth_num++);
        }
 
 int SSL_CTX_set_ex_data(SSL_CTX *s,int idx,void *arg)
index 1b87de9d21ce778009f03da1064b98b93d4b45ec..5821792b7651e303556e981bb7a319416f1fa6e6 100644 (file)
@@ -91,10 +91,10 @@ SSL_SESSION *SSL_get1_session(SSL *ssl)
 int SSL_SESSION_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
             CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func)
        {
-       ssl_session_num++;
-       return(CRYPTO_get_ex_new_index(ssl_session_num-1,
-               &ssl_session_meth,
-               argl,argp,new_func,dup_func,free_func));
+       if(CRYPTO_get_ex_new_index(ssl_session_num, &ssl_session_meth, argl,
+                               argp, new_func, dup_func, free_func) < 0)
+               return -1;
+       return (ssl_session_num++);
        }
 
 int SSL_SESSION_set_ex_data(SSL_SESSION *s, int idx, void *arg)