summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ex_data.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/ex_data.c')
-rw-r--r--src/lib/libcrypto/ex_data.c57
1 files changed, 22 insertions, 35 deletions
diff --git a/src/lib/libcrypto/ex_data.c b/src/lib/libcrypto/ex_data.c
index c858b518ff..176574766b 100644
--- a/src/lib/libcrypto/ex_data.c
+++ b/src/lib/libcrypto/ex_data.c
@@ -58,34 +58,30 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include "buffer.h" 61#include <openssl/buffer.h>
62#include "bio.h" 62#include <openssl/bio.h>
63#include "lhash.h" 63#include <openssl/lhash.h>
64#include "cryptlib.h" 64#include "cryptlib.h"
65 65
66int CRYPTO_get_ex_new_index(idx,skp,argl,argp,new_func,dup_func,free_func) 66int CRYPTO_get_ex_new_index(int idx, STACK **skp, long argl, char *argp,
67int idx; 67 int (*new_func)(), int (*dup_func)(), void (*free_func)())
68STACK **skp;
69long argl;
70char *argp;
71int (*new_func)();
72int (*dup_func)();
73void (*free_func)();
74 { 68 {
69 int ret= -1;
75 CRYPTO_EX_DATA_FUNCS *a; 70 CRYPTO_EX_DATA_FUNCS *a;
76 71
72 MemCheck_off();
77 if (*skp == NULL) 73 if (*skp == NULL)
78 *skp=sk_new_null(); 74 *skp=sk_new_null();
79 if (*skp == NULL) 75 if (*skp == NULL)
80 { 76 {
81 CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX,ERR_R_MALLOC_FAILURE); 77 CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX,ERR_R_MALLOC_FAILURE);
82 return(-1); 78 goto err;
83 } 79 }
84 a=(CRYPTO_EX_DATA_FUNCS *)Malloc(sizeof(CRYPTO_EX_DATA_FUNCS)); 80 a=(CRYPTO_EX_DATA_FUNCS *)Malloc(sizeof(CRYPTO_EX_DATA_FUNCS));
85 if (a == NULL) 81 if (a == NULL)
86 { 82 {
87 CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX,ERR_R_MALLOC_FAILURE); 83 CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX,ERR_R_MALLOC_FAILURE);
88 return(-1); 84 goto err;
89 } 85 }
90 a->argl=argl; 86 a->argl=argl;
91 a->argp=argp; 87 a->argp=argp;
@@ -98,17 +94,17 @@ void (*free_func)();
98 { 94 {
99 CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX,ERR_R_MALLOC_FAILURE); 95 CRYPTOerr(CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX,ERR_R_MALLOC_FAILURE);
100 Free(a); 96 Free(a);
101 return(-1); 97 goto err;
102 } 98 }
103 } 99 }
104 sk_value(*skp,idx)=(char *)a; 100 sk_set(*skp,idx, (char *)a);
101 ret=idx;
102err:
103 MemCheck_on();
105 return(idx); 104 return(idx);
106 } 105 }
107 106
108int CRYPTO_set_ex_data(ad,idx,val) 107int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, char *val)
109CRYPTO_EX_DATA *ad;
110int idx;
111char *val;
112 { 108 {
113 int i; 109 int i;
114 110
@@ -131,13 +127,11 @@ char *val;
131 } 127 }
132 i++; 128 i++;
133 } 129 }
134 sk_value(ad->sk,idx)=val; 130 sk_set(ad->sk,idx,val);
135 return(1); 131 return(1);
136 } 132 }
137 133
138char *CRYPTO_get_ex_data(ad,idx) 134char *CRYPTO_get_ex_data(CRYPTO_EX_DATA *ad, int idx)
139CRYPTO_EX_DATA *ad;
140int idx;
141 { 135 {
142 if (ad->sk == NULL) 136 if (ad->sk == NULL)
143 return(0); 137 return(0);
@@ -147,13 +141,12 @@ int idx;
147 return(sk_value(ad->sk,idx)); 141 return(sk_value(ad->sk,idx));
148 } 142 }
149 143
150/* The callback is called with the 'object', which is the origional data object 144/* The callback is called with the 'object', which is the original data object
151 * being duplicated, a pointer to the 145 * being duplicated, a pointer to the
152 * 'new' object to be inserted, the index, and the argi/argp 146 * 'new' object to be inserted, the index, and the argi/argp
153 */ 147 */
154int CRYPTO_dup_ex_data(meth,to,from) 148int CRYPTO_dup_ex_data(STACK *meth, CRYPTO_EX_DATA *to,
155STACK *meth; 149 CRYPTO_EX_DATA *from)
156CRYPTO_EX_DATA *to,*from;
157 { 150 {
158 int i,j,m,r; 151 int i,j,m,r;
159 CRYPTO_EX_DATA_FUNCS *mm; 152 CRYPTO_EX_DATA_FUNCS *mm;
@@ -179,10 +172,7 @@ CRYPTO_EX_DATA *to,*from;
179 } 172 }
180 173
181/* Call each free callback */ 174/* Call each free callback */
182void CRYPTO_free_ex_data(meth,obj,ad) 175void CRYPTO_free_ex_data(STACK *meth, char *obj, CRYPTO_EX_DATA *ad)
183STACK *meth;
184char *obj;
185CRYPTO_EX_DATA *ad;
186 { 176 {
187 CRYPTO_EX_DATA_FUNCS *m; 177 CRYPTO_EX_DATA_FUNCS *m;
188 char *ptr; 178 char *ptr;
@@ -208,10 +198,7 @@ CRYPTO_EX_DATA *ad;
208 } 198 }
209 } 199 }
210 200
211void CRYPTO_new_ex_data(meth,obj,ad) 201void CRYPTO_new_ex_data(STACK *meth, char *obj, CRYPTO_EX_DATA *ad)
212STACK *meth;
213char *obj;
214CRYPTO_EX_DATA *ad;
215 { 202 {
216 CRYPTO_EX_DATA_FUNCS *m; 203 CRYPTO_EX_DATA_FUNCS *m;
217 char *ptr; 204 char *ptr;