Commit b7727ee6 authored by Geoff Thorpe's avatar Geoff Thorpe
Browse files

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.
parent f0446ca8
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -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)
+4 −3
Original line number Diff line number Diff line
@@ -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)
+4 −3
Original line number Diff line number Diff line
@@ -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)
+4 −3
Original line number Diff line number Diff line
@@ -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)
+4 −3
Original line number Diff line number Diff line
@@ -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)
Loading