summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/tasn_fre.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/tasn_fre.c')
-rw-r--r--src/lib/libcrypto/asn1/tasn_fre.c76
1 files changed, 38 insertions, 38 deletions
diff --git a/src/lib/libcrypto/asn1/tasn_fre.c b/src/lib/libcrypto/asn1/tasn_fre.c
index b04034ba4c..b321de6615 100644
--- a/src/lib/libcrypto/asn1/tasn_fre.c
+++ b/src/lib/libcrypto/asn1/tasn_fre.c
@@ -67,17 +67,17 @@ static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int c
67/* Free up an ASN1 structure */ 67/* Free up an ASN1 structure */
68 68
69void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it) 69void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it)
70 { 70{
71 asn1_item_combine_free(&val, it, 0); 71 asn1_item_combine_free(&val, it, 0);
72 } 72}
73 73
74void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it) 74void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
75 { 75{
76 asn1_item_combine_free(pval, it, 0); 76 asn1_item_combine_free(pval, it, 0);
77 } 77}
78 78
79static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine) 79static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine)
80 { 80{
81 const ASN1_TEMPLATE *tt = NULL, *seqtt; 81 const ASN1_TEMPLATE *tt = NULL, *seqtt;
82 const ASN1_EXTERN_FUNCS *ef; 82 const ASN1_EXTERN_FUNCS *ef;
83 const ASN1_COMPAT_FUNCS *cf; 83 const ASN1_COMPAT_FUNCS *cf;
@@ -94,7 +94,7 @@ static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int c
94 asn1_cb = 0; 94 asn1_cb = 0;
95 95
96 switch(it->itype) 96 switch(it->itype)
97 { 97 {
98 98
99 case ASN1_ITYPE_PRIMITIVE: 99 case ASN1_ITYPE_PRIMITIVE:
100 if (it->templates) 100 if (it->templates)
@@ -109,26 +109,26 @@ static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int c
109 109
110 case ASN1_ITYPE_CHOICE: 110 case ASN1_ITYPE_CHOICE:
111 if (asn1_cb) 111 if (asn1_cb)
112 { 112 {
113 i = asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL); 113 i = asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL);
114 if (i == 2) 114 if (i == 2)
115 return; 115 return;
116 } 116 }
117 i = asn1_get_choice_selector(pval, it); 117 i = asn1_get_choice_selector(pval, it);
118 if ((i >= 0) && (i < it->tcount)) 118 if ((i >= 0) && (i < it->tcount))
119 { 119 {
120 ASN1_VALUE **pchval; 120 ASN1_VALUE **pchval;
121 tt = it->templates + i; 121 tt = it->templates + i;
122 pchval = asn1_get_field_ptr(pval, tt); 122 pchval = asn1_get_field_ptr(pval, tt);
123 ASN1_template_free(pchval, tt); 123 ASN1_template_free(pchval, tt);
124 } 124 }
125 if (asn1_cb) 125 if (asn1_cb)
126 asn1_cb(ASN1_OP_FREE_POST, pval, it, NULL); 126 asn1_cb(ASN1_OP_FREE_POST, pval, it, NULL);
127 if (!combine) 127 if (!combine)
128 { 128 {
129 free(*pval); 129 free(*pval);
130 *pval = NULL; 130 *pval = NULL;
131 } 131 }
132 break; 132 break;
133 133
134 case ASN1_ITYPE_COMPAT: 134 case ASN1_ITYPE_COMPAT:
@@ -148,11 +148,11 @@ static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int c
148 if (asn1_do_lock(pval, -1, it) > 0) 148 if (asn1_do_lock(pval, -1, it) > 0)
149 return; 149 return;
150 if (asn1_cb) 150 if (asn1_cb)
151 { 151 {
152 i = asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL); 152 i = asn1_cb(ASN1_OP_FREE_PRE, pval, it, NULL);
153 if (i == 2) 153 if (i == 2)
154 return; 154 return;
155 } 155 }
156 asn1_enc_free(pval, it); 156 asn1_enc_free(pval, it);
157 /* If we free up as normal we will invalidate any 157 /* If we free up as normal we will invalidate any
158 * ANY DEFINED BY field and we wont be able to 158 * ANY DEFINED BY field and we wont be able to
@@ -161,83 +161,83 @@ static void asn1_item_combine_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int c
161 */ 161 */
162 tt = it->templates + it->tcount - 1; 162 tt = it->templates + it->tcount - 1;
163 for (i = 0; i < it->tcount; tt--, i++) 163 for (i = 0; i < it->tcount; tt--, i++)
164 { 164 {
165 ASN1_VALUE **pseqval; 165 ASN1_VALUE **pseqval;
166 seqtt = asn1_do_adb(pval, tt, 0); 166 seqtt = asn1_do_adb(pval, tt, 0);
167 if (!seqtt) 167 if (!seqtt)
168 continue; 168 continue;
169 pseqval = asn1_get_field_ptr(pval, seqtt); 169 pseqval = asn1_get_field_ptr(pval, seqtt);
170 ASN1_template_free(pseqval, seqtt); 170 ASN1_template_free(pseqval, seqtt);
171 } 171 }
172 if (asn1_cb) 172 if (asn1_cb)
173 asn1_cb(ASN1_OP_FREE_POST, pval, it, NULL); 173 asn1_cb(ASN1_OP_FREE_POST, pval, it, NULL);
174 if (!combine) 174 if (!combine)
175 { 175 {
176 free(*pval); 176 free(*pval);
177 *pval = NULL; 177 *pval = NULL;
178 }
179 break;
180 } 178 }
179 break;
181 } 180 }
181}
182 182
183void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) 183void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt)
184 { 184{
185 int i; 185 int i;
186 if (tt->flags & ASN1_TFLG_SK_MASK) 186 if (tt->flags & ASN1_TFLG_SK_MASK)
187 { 187 {
188 STACK_OF(ASN1_VALUE) *sk = (STACK_OF(ASN1_VALUE) *)*pval; 188 STACK_OF(ASN1_VALUE) *sk = (STACK_OF(ASN1_VALUE) *)*pval;
189 for (i = 0; i < sk_ASN1_VALUE_num(sk); i++) 189 for (i = 0; i < sk_ASN1_VALUE_num(sk); i++)
190 { 190 {
191 ASN1_VALUE *vtmp; 191 ASN1_VALUE *vtmp;
192 vtmp = sk_ASN1_VALUE_value(sk, i); 192 vtmp = sk_ASN1_VALUE_value(sk, i);
193 asn1_item_combine_free(&vtmp, ASN1_ITEM_ptr(tt->item), 193 asn1_item_combine_free(&vtmp, ASN1_ITEM_ptr(tt->item),
194 0); 194 0);
195 } 195 }
196 sk_ASN1_VALUE_free(sk); 196 sk_ASN1_VALUE_free(sk);
197 *pval = NULL; 197 *pval = NULL;
198 } 198 }
199 else 199 else
200 asn1_item_combine_free(pval, ASN1_ITEM_ptr(tt->item), 200 asn1_item_combine_free(pval, ASN1_ITEM_ptr(tt->item),
201 tt->flags & ASN1_TFLG_COMBINE); 201 tt->flags & ASN1_TFLG_COMBINE);
202 } 202}
203 203
204void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it) 204void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
205 { 205{
206 int utype; 206 int utype;
207 if (it) 207 if (it)
208 { 208 {
209 const ASN1_PRIMITIVE_FUNCS *pf; 209 const ASN1_PRIMITIVE_FUNCS *pf;
210 pf = it->funcs; 210 pf = it->funcs;
211 if (pf && pf->prim_free) 211 if (pf && pf->prim_free)
212 { 212 {
213 pf->prim_free(pval, it); 213 pf->prim_free(pval, it);
214 return; 214 return;
215 }
216 } 215 }
216 }
217 /* Special case: if 'it' is NULL free contents of ASN1_TYPE */ 217 /* Special case: if 'it' is NULL free contents of ASN1_TYPE */
218 if (!it) 218 if (!it)
219 { 219 {
220 ASN1_TYPE *typ = (ASN1_TYPE *)*pval; 220 ASN1_TYPE *typ = (ASN1_TYPE *)*pval;
221 utype = typ->type; 221 utype = typ->type;
222 pval = &typ->value.asn1_value; 222 pval = &typ->value.asn1_value;
223 if (!*pval) 223 if (!*pval)
224 return; 224 return;
225 } 225 }
226 else if (it->itype == ASN1_ITYPE_MSTRING) 226 else if (it->itype == ASN1_ITYPE_MSTRING)
227 { 227 {
228 utype = -1; 228 utype = -1;
229 if (!*pval) 229 if (!*pval)
230 return; 230 return;
231 } 231 }
232 else 232 else
233 { 233 {
234 utype = it->utype; 234 utype = it->utype;
235 if ((utype != V_ASN1_BOOLEAN) && !*pval) 235 if ((utype != V_ASN1_BOOLEAN) && !*pval)
236 return; 236 return;
237 } 237 }
238 238
239 switch(utype) 239 switch(utype)
240 { 240 {
241 case V_ASN1_OBJECT: 241 case V_ASN1_OBJECT:
242 ASN1_OBJECT_free((ASN1_OBJECT *)*pval); 242 ASN1_OBJECT_free((ASN1_OBJECT *)*pval);
243 break; 243 break;
@@ -261,6 +261,6 @@ void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it)
261 ASN1_STRING_free((ASN1_STRING *)*pval); 261 ASN1_STRING_free((ASN1_STRING *)*pval);
262 *pval = NULL; 262 *pval = NULL;
263 break; 263 break;
264 }
265 *pval = NULL;
266 } 264 }
265 *pval = NULL;
266}