Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/asn1/tasn_new.c |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /* $OpenBSD: tasn_new.c,v 1.17 2017/01/29 17:49:22 beck Exp $ */ | - | ||||||||||||
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | - | ||||||||||||
3 | * project 2000. | - | ||||||||||||
4 | */ | - | ||||||||||||
5 | /* ==================================================================== | - | ||||||||||||
6 | * Copyright (c) 2000-2004 The OpenSSL Project. All rights reserved. | - | ||||||||||||
7 | * | - | ||||||||||||
8 | * Redistribution and use in source and binary forms, with or without | - | ||||||||||||
9 | * modification, are permitted provided that the following conditions | - | ||||||||||||
10 | * are met: | - | ||||||||||||
11 | * | - | ||||||||||||
12 | * 1. Redistributions of source code must retain the above copyright | - | ||||||||||||
13 | * notice, this list of conditions and the following disclaimer. | - | ||||||||||||
14 | * | - | ||||||||||||
15 | * 2. Redistributions in binary form must reproduce the above copyright | - | ||||||||||||
16 | * notice, this list of conditions and the following disclaimer in | - | ||||||||||||
17 | * the documentation and/or other materials provided with the | - | ||||||||||||
18 | * distribution. | - | ||||||||||||
19 | * | - | ||||||||||||
20 | * 3. All advertising materials mentioning features or use of this | - | ||||||||||||
21 | * software must display the following acknowledgment: | - | ||||||||||||
22 | * "This product includes software developed by the OpenSSL Project | - | ||||||||||||
23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | - | ||||||||||||
24 | * | - | ||||||||||||
25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | - | ||||||||||||
26 | * endorse or promote products derived from this software without | - | ||||||||||||
27 | * prior written permission. For written permission, please contact | - | ||||||||||||
28 | * licensing@OpenSSL.org. | - | ||||||||||||
29 | * | - | ||||||||||||
30 | * 5. Products derived from this software may not be called "OpenSSL" | - | ||||||||||||
31 | * nor may "OpenSSL" appear in their names without prior written | - | ||||||||||||
32 | * permission of the OpenSSL Project. | - | ||||||||||||
33 | * | - | ||||||||||||
34 | * 6. Redistributions of any form whatsoever must retain the following | - | ||||||||||||
35 | * acknowledgment: | - | ||||||||||||
36 | * "This product includes software developed by the OpenSSL Project | - | ||||||||||||
37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | - | ||||||||||||
38 | * | - | ||||||||||||
39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | - | ||||||||||||
40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | - | ||||||||||||
41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | - | ||||||||||||
42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | - | ||||||||||||
43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | - | ||||||||||||
44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | - | ||||||||||||
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | - | ||||||||||||
46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | - | ||||||||||||
47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | - | ||||||||||||
48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | - | ||||||||||||
49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | - | ||||||||||||
50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | - | ||||||||||||
51 | * ==================================================================== | - | ||||||||||||
52 | * | - | ||||||||||||
53 | * This product includes cryptographic software written by Eric Young | - | ||||||||||||
54 | * (eay@cryptsoft.com). This product includes software written by Tim | - | ||||||||||||
55 | * Hudson (tjh@cryptsoft.com). | - | ||||||||||||
56 | * | - | ||||||||||||
57 | */ | - | ||||||||||||
58 | - | |||||||||||||
59 | - | |||||||||||||
60 | #include <stddef.h> | - | ||||||||||||
61 | #include <openssl/asn1.h> | - | ||||||||||||
62 | #include <openssl/objects.h> | - | ||||||||||||
63 | #include <openssl/err.h> | - | ||||||||||||
64 | #include <openssl/asn1t.h> | - | ||||||||||||
65 | #include <string.h> | - | ||||||||||||
66 | - | |||||||||||||
67 | static int asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it, | - | ||||||||||||
68 | int combine); | - | ||||||||||||
69 | static void asn1_item_clear(ASN1_VALUE **pval, const ASN1_ITEM *it); | - | ||||||||||||
70 | static void asn1_template_clear(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); | - | ||||||||||||
71 | static void asn1_primitive_clear(ASN1_VALUE **pval, const ASN1_ITEM *it); | - | ||||||||||||
72 | - | |||||||||||||
73 | ASN1_VALUE * | - | ||||||||||||
74 | ASN1_item_new(const ASN1_ITEM *it) | - | ||||||||||||
75 | { | - | ||||||||||||
76 | ASN1_VALUE *ret = NULL; | - | ||||||||||||
77 | if (ASN1_item_ex_new(&ret, it) > 0)
| 0-3832 | ||||||||||||
78 | return ret; executed 3832 times by 12 tests: return ret; Executed by:
| 3832 | ||||||||||||
79 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
80 | } | - | ||||||||||||
81 | - | |||||||||||||
82 | /* Allocate an ASN1 structure */ | - | ||||||||||||
83 | - | |||||||||||||
84 | int | - | ||||||||||||
85 | ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it) | - | ||||||||||||
86 | { | - | ||||||||||||
87 | return asn1_item_ex_combine_new(pval, it, 0); executed 7415 times by 12 tests: return asn1_item_ex_combine_new(pval, it, 0); Executed by:
| 7415 | ||||||||||||
88 | } | - | ||||||||||||
89 | - | |||||||||||||
90 | static int | - | ||||||||||||
91 | asn1_item_ex_combine_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int combine) | - | ||||||||||||
92 | { | - | ||||||||||||
93 | const ASN1_TEMPLATE *tt = NULL; | - | ||||||||||||
94 | const ASN1_EXTERN_FUNCS *ef; | - | ||||||||||||
95 | const ASN1_AUX *aux = it->funcs; | - | ||||||||||||
96 | ASN1_aux_cb *asn1_cb = NULL; | - | ||||||||||||
97 | ASN1_VALUE **pseqval; | - | ||||||||||||
98 | int i; | - | ||||||||||||
99 | - | |||||||||||||
100 | if (aux != NULL && aux->asn1_cb != NULL)
| 782-18788 | ||||||||||||
101 | asn1_cb = aux->asn1_cb; executed 2137 times by 9 tests: asn1_cb = aux->asn1_cb; Executed by:
| 2137 | ||||||||||||
102 | - | |||||||||||||
103 | if (!combine)
| 16-21691 | ||||||||||||
104 | *pval = NULL; executed 21691 times by 12 tests: *pval = ((void *)0) ; Executed by:
| 21691 | ||||||||||||
105 | - | |||||||||||||
106 | #ifdef CRYPTO_MDEBUG | - | ||||||||||||
107 | if (it->sname) | - | ||||||||||||
108 | CRYPTO_push_info(it->sname); | - | ||||||||||||
109 | #endif | - | ||||||||||||
110 | - | |||||||||||||
111 | switch (it->itype) { | - | ||||||||||||
112 | case ASN1_ITYPE_EXTERN: executed 531 times by 8 tests: case 0x4: Executed by:
| 531 | ||||||||||||
113 | ef = it->funcs; | - | ||||||||||||
114 | if (ef && ef->asn1_ex_new) {
| 0-531 | ||||||||||||
115 | if (!ef->asn1_ex_new(pval, it))
| 0-531 | ||||||||||||
116 | goto memerr; never executed: goto memerr; | 0 | ||||||||||||
117 | } executed 531 times by 8 tests: end of block Executed by:
| 531 | ||||||||||||
118 | break; executed 531 times by 8 tests: break; Executed by:
| 531 | ||||||||||||
119 | - | |||||||||||||
120 | case ASN1_ITYPE_PRIMITIVE: executed 9258 times by 12 tests: case 0x0: Executed by:
| 9258 | ||||||||||||
121 | if (it->templates) {
| 0-9258 | ||||||||||||
122 | if (!ASN1_template_new(pval, it->templates))
| 0 | ||||||||||||
123 | goto memerr; never executed: goto memerr; | 0 | ||||||||||||
124 | } else if (!ASN1_primitive_new(pval, it)) never executed: end of block
| 0-9258 | ||||||||||||
125 | goto memerr; never executed: goto memerr; | 0 | ||||||||||||
126 | break; executed 9258 times by 12 tests: break; Executed by:
| 9258 | ||||||||||||
127 | - | |||||||||||||
128 | case ASN1_ITYPE_MSTRING: executed 4265 times by 10 tests: case 0x5: Executed by:
| 4265 | ||||||||||||
129 | if (!ASN1_primitive_new(pval, it))
| 0-4265 | ||||||||||||
130 | goto memerr; never executed: goto memerr; | 0 | ||||||||||||
131 | break; executed 4265 times by 10 tests: break; Executed by:
| 4265 | ||||||||||||
132 | - | |||||||||||||
133 | case ASN1_ITYPE_CHOICE: executed 64 times by 2 tests: case 0x2: Executed by:
| 64 | ||||||||||||
134 | if (asn1_cb) {
| 0-64 | ||||||||||||
135 | i = asn1_cb(ASN1_OP_NEW_PRE, pval, it, NULL); | - | ||||||||||||
136 | if (!i)
| 0 | ||||||||||||
137 | goto auxerr; never executed: goto auxerr; | 0 | ||||||||||||
138 | if (i == 2) {
| 0 | ||||||||||||
139 | #ifdef CRYPTO_MDEBUG | - | ||||||||||||
140 | if (it->sname) | - | ||||||||||||
141 | CRYPTO_pop_info(); | - | ||||||||||||
142 | #endif | - | ||||||||||||
143 | return 1; never executed: return 1; | 0 | ||||||||||||
144 | } | - | ||||||||||||
145 | } never executed: end of block | 0 | ||||||||||||
146 | if (!combine) {
| 16-48 | ||||||||||||
147 | *pval = calloc(1, it->size); | - | ||||||||||||
148 | if (!*pval)
| 0-48 | ||||||||||||
149 | goto memerr; never executed: goto memerr; | 0 | ||||||||||||
150 | } executed 48 times by 1 test: end of block Executed by:
| 48 | ||||||||||||
151 | asn1_set_choice_selector(pval, -1, it); | - | ||||||||||||
152 | if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL))
| 0-64 | ||||||||||||
153 | goto auxerr; never executed: goto auxerr; | 0 | ||||||||||||
154 | break; executed 64 times by 2 tests: break; Executed by:
| 64 | ||||||||||||
155 | - | |||||||||||||
156 | case ASN1_ITYPE_NDEF_SEQUENCE: executed 20 times by 1 test: case 0x6: Executed by:
| 20 | ||||||||||||
157 | case ASN1_ITYPE_SEQUENCE: executed 7569 times by 10 tests: case 0x1: Executed by:
| 7569 | ||||||||||||
158 | if (asn1_cb) {
| 921-6668 | ||||||||||||
159 | i = asn1_cb(ASN1_OP_NEW_PRE, pval, it, NULL); | - | ||||||||||||
160 | if (!i)
| 0-921 | ||||||||||||
161 | goto auxerr; never executed: goto auxerr; | 0 | ||||||||||||
162 | if (i == 2) {
| 396-525 | ||||||||||||
163 | #ifdef CRYPTO_MDEBUG | - | ||||||||||||
164 | if (it->sname) | - | ||||||||||||
165 | CRYPTO_pop_info(); | - | ||||||||||||
166 | #endif | - | ||||||||||||
167 | return 1; executed 396 times by 5 tests: return 1; Executed by:
| 396 | ||||||||||||
168 | } | - | ||||||||||||
169 | } executed 525 times by 8 tests: end of block Executed by:
| 525 | ||||||||||||
170 | if (!combine) {
| 0-7193 | ||||||||||||
171 | *pval = calloc(1, it->size); | - | ||||||||||||
172 | if (!*pval)
| 0-7193 | ||||||||||||
173 | goto memerr; never executed: goto memerr; | 0 | ||||||||||||
174 | asn1_do_lock(pval, 0, it); | - | ||||||||||||
175 | asn1_enc_init(pval, it); | - | ||||||||||||
176 | } executed 7193 times by 10 tests: end of block Executed by:
| 7193 | ||||||||||||
177 | for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) {
| 7193-17502 | ||||||||||||
178 | pseqval = asn1_get_field_ptr(pval, tt); | - | ||||||||||||
179 | if (!ASN1_template_new(pseqval, tt))
| 0-17502 | ||||||||||||
180 | goto memerr; never executed: goto memerr; | 0 | ||||||||||||
181 | } executed 17502 times by 10 tests: end of block Executed by:
| 17502 | ||||||||||||
182 | if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL))
| 0-6668 | ||||||||||||
183 | goto auxerr; never executed: goto auxerr; | 0 | ||||||||||||
184 | break; executed 7193 times by 10 tests: break; Executed by:
| 7193 | ||||||||||||
185 | } | - | ||||||||||||
186 | #ifdef CRYPTO_MDEBUG | - | ||||||||||||
187 | if (it->sname) | - | ||||||||||||
188 | CRYPTO_pop_info(); | - | ||||||||||||
189 | #endif | - | ||||||||||||
190 | return 1; executed 21311 times by 12 tests: return 1; Executed by:
| 21311 | ||||||||||||
191 | - | |||||||||||||
192 | memerr: | - | ||||||||||||
193 | ASN1error(ERR_R_MALLOC_FAILURE); | - | ||||||||||||
194 | #ifdef CRYPTO_MDEBUG | - | ||||||||||||
195 | if (it->sname) | - | ||||||||||||
196 | CRYPTO_pop_info(); | - | ||||||||||||
197 | #endif | - | ||||||||||||
198 | return 0; never executed: return 0; | 0 | ||||||||||||
199 | - | |||||||||||||
200 | auxerr: | - | ||||||||||||
201 | ASN1error(ASN1_R_AUX_ERROR); | - | ||||||||||||
202 | ASN1_item_ex_free(pval, it); | - | ||||||||||||
203 | #ifdef CRYPTO_MDEBUG | - | ||||||||||||
204 | if (it->sname) | - | ||||||||||||
205 | CRYPTO_pop_info(); | - | ||||||||||||
206 | #endif | - | ||||||||||||
207 | return 0; never executed: return 0; | 0 | ||||||||||||
208 | - | |||||||||||||
209 | } | - | ||||||||||||
210 | - | |||||||||||||
211 | static void | - | ||||||||||||
212 | asn1_item_clear(ASN1_VALUE **pval, const ASN1_ITEM *it) | - | ||||||||||||
213 | { | - | ||||||||||||
214 | const ASN1_EXTERN_FUNCS *ef; | - | ||||||||||||
215 | - | |||||||||||||
216 | switch (it->itype) { | - | ||||||||||||
217 | case ASN1_ITYPE_EXTERN: never executed: case 0x4: | 0 | ||||||||||||
218 | ef = it->funcs; | - | ||||||||||||
219 | if (ef && ef->asn1_ex_clear)
| 0 | ||||||||||||
220 | ef->asn1_ex_clear(pval, it); never executed: ef->asn1_ex_clear(pval, it); | 0 | ||||||||||||
221 | else | - | ||||||||||||
222 | *pval = NULL; never executed: *pval = ((void *)0) ; | 0 | ||||||||||||
223 | break; never executed: break; | 0 | ||||||||||||
224 | - | |||||||||||||
225 | case ASN1_ITYPE_PRIMITIVE: executed 2843 times by 8 tests: case 0x0: Executed by:
| 2843 | ||||||||||||
226 | if (it->templates)
| 0-2843 | ||||||||||||
227 | asn1_template_clear(pval, it->templates); never executed: asn1_template_clear(pval, it->templates); | 0 | ||||||||||||
228 | else | - | ||||||||||||
229 | asn1_primitive_clear(pval, it); executed 2843 times by 8 tests: asn1_primitive_clear(pval, it); Executed by:
| 2843 | ||||||||||||
230 | break; executed 2843 times by 8 tests: break; Executed by:
| 2843 | ||||||||||||
231 | - | |||||||||||||
232 | case ASN1_ITYPE_MSTRING: never executed: case 0x5: | 0 | ||||||||||||
233 | asn1_primitive_clear(pval, it); | - | ||||||||||||
234 | break; never executed: break; | 0 | ||||||||||||
235 | - | |||||||||||||
236 | case ASN1_ITYPE_CHOICE: never executed: case 0x2: | 0 | ||||||||||||
237 | case ASN1_ITYPE_SEQUENCE: never executed: case 0x1: | 0 | ||||||||||||
238 | case ASN1_ITYPE_NDEF_SEQUENCE: never executed: case 0x6: | 0 | ||||||||||||
239 | *pval = NULL; | - | ||||||||||||
240 | break; never executed: break; | 0 | ||||||||||||
241 | } | - | ||||||||||||
242 | } executed 2843 times by 8 tests: end of block Executed by:
| 2843 | ||||||||||||
243 | - | |||||||||||||
244 | int | - | ||||||||||||
245 | ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) | - | ||||||||||||
246 | { | - | ||||||||||||
247 | const ASN1_ITEM *it = tt->item; | - | ||||||||||||
248 | int ret; | - | ||||||||||||
249 | - | |||||||||||||
250 | if (tt->flags & ASN1_TFLG_OPTIONAL) {
| 3188-14314 | ||||||||||||
251 | asn1_template_clear(pval, tt); | - | ||||||||||||
252 | return 1; executed 3188 times by 8 tests: return 1; Executed by:
| 3188 | ||||||||||||
253 | } | - | ||||||||||||
254 | /* If ANY DEFINED BY nothing to do */ | - | ||||||||||||
255 | - | |||||||||||||
256 | if (tt->flags & ASN1_TFLG_ADB_MASK) {
| 12-14302 | ||||||||||||
257 | *pval = NULL; | - | ||||||||||||
258 | return 1; executed 12 times by 1 test: return 1; Executed by:
| 12 | ||||||||||||
259 | } | - | ||||||||||||
260 | #ifdef CRYPTO_MDEBUG | - | ||||||||||||
261 | if (tt->field_name) | - | ||||||||||||
262 | CRYPTO_push_info(tt->field_name); | - | ||||||||||||
263 | #endif | - | ||||||||||||
264 | /* If SET OF or SEQUENCE OF, its a STACK */ | - | ||||||||||||
265 | if (tt->flags & ASN1_TFLG_SK_MASK) {
| 10-14292 | ||||||||||||
266 | STACK_OF(ASN1_VALUE) *skval; | - | ||||||||||||
267 | skval = sk_ASN1_VALUE_new_null(); | - | ||||||||||||
268 | if (!skval) {
| 0-10 | ||||||||||||
269 | ASN1error(ERR_R_MALLOC_FAILURE); | - | ||||||||||||
270 | ret = 0; | - | ||||||||||||
271 | goto done; never executed: goto done; | 0 | ||||||||||||
272 | } | - | ||||||||||||
273 | *pval = (ASN1_VALUE *)skval; | - | ||||||||||||
274 | ret = 1; | - | ||||||||||||
275 | goto done; executed 10 times by 1 test: goto done; Executed by:
| 10 | ||||||||||||
276 | } | - | ||||||||||||
277 | /* Otherwise pass it back to the item routine */ | - | ||||||||||||
278 | ret = asn1_item_ex_combine_new(pval, it, tt->flags & ASN1_TFLG_COMBINE); | - | ||||||||||||
279 | done: code before this statement executed 14292 times by 10 tests: done: Executed by:
| 14292 | ||||||||||||
280 | #ifdef CRYPTO_MDEBUG | - | ||||||||||||
281 | if (it->sname) | - | ||||||||||||
282 | CRYPTO_pop_info(); | - | ||||||||||||
283 | #endif | - | ||||||||||||
284 | return ret; executed 14302 times by 10 tests: return ret; Executed by:
| 14302 | ||||||||||||
285 | } | - | ||||||||||||
286 | - | |||||||||||||
287 | static void | - | ||||||||||||
288 | asn1_template_clear(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) | - | ||||||||||||
289 | { | - | ||||||||||||
290 | /* If ADB or STACK just NULL the field */ | - | ||||||||||||
291 | if (tt->flags & (ASN1_TFLG_ADB_MASK|ASN1_TFLG_SK_MASK))
| 345-2843 | ||||||||||||
292 | *pval = NULL; executed 345 times by 8 tests: *pval = ((void *)0) ; Executed by:
| 345 | ||||||||||||
293 | else | - | ||||||||||||
294 | asn1_item_clear(pval, tt->item); executed 2843 times by 8 tests: asn1_item_clear(pval, tt->item); Executed by:
| 2843 | ||||||||||||
295 | } | - | ||||||||||||
296 | - | |||||||||||||
297 | - | |||||||||||||
298 | /* NB: could probably combine most of the real XXX_new() behaviour and junk | - | ||||||||||||
299 | * all the old functions. | - | ||||||||||||
300 | */ | - | ||||||||||||
301 | - | |||||||||||||
302 | int | - | ||||||||||||
303 | ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it) | - | ||||||||||||
304 | { | - | ||||||||||||
305 | ASN1_TYPE *typ; | - | ||||||||||||
306 | ASN1_STRING *str; | - | ||||||||||||
307 | int utype; | - | ||||||||||||
308 | - | |||||||||||||
309 | if (it && it->funcs) {
| 0-13523 | ||||||||||||
310 | const ASN1_PRIMITIVE_FUNCS *pf = it->funcs; | - | ||||||||||||
311 | if (pf->prim_new)
| 0-1216 | ||||||||||||
312 | return pf->prim_new(pval, it); executed 1216 times by 1 test: return pf->prim_new(pval, it); Executed by:
| 1216 | ||||||||||||
313 | } never executed: end of block | 0 | ||||||||||||
314 | - | |||||||||||||
315 | if (!it || (it->itype == ASN1_ITYPE_MSTRING))
| 0-12307 | ||||||||||||
316 | utype = V_ASN1_UNDEF; executed 4265 times by 10 tests: utype = -1; Executed by:
| 4265 | ||||||||||||
317 | else | - | ||||||||||||
318 | utype = it->utype; executed 8042 times by 11 tests: utype = it->utype; Executed by:
| 8042 | ||||||||||||
319 | switch (utype) { | - | ||||||||||||
320 | case V_ASN1_OBJECT: executed 5281 times by 8 tests: case 6: Executed by:
| 5281 | ||||||||||||
321 | *pval = (ASN1_VALUE *)OBJ_nid2obj(NID_undef); | - | ||||||||||||
322 | return 1; executed 5281 times by 8 tests: return 1; Executed by:
| 5281 | ||||||||||||
323 | - | |||||||||||||
324 | case V_ASN1_BOOLEAN: never executed: case 1: | 0 | ||||||||||||
325 | *(ASN1_BOOLEAN *)pval = it->size; | - | ||||||||||||
326 | return 1; never executed: return 1; | 0 | ||||||||||||
327 | - | |||||||||||||
328 | case V_ASN1_NULL: never executed: case 5: | 0 | ||||||||||||
329 | *pval = (ASN1_VALUE *)1; | - | ||||||||||||
330 | return 1; never executed: return 1; | 0 | ||||||||||||
331 | - | |||||||||||||
332 | case V_ASN1_ANY: executed 700 times by 7 tests: case -4: Executed by:
| 700 | ||||||||||||
333 | typ = malloc(sizeof(ASN1_TYPE)); | - | ||||||||||||
334 | if (typ != NULL) {
| 0-700 | ||||||||||||
335 | typ->value.ptr = NULL; | - | ||||||||||||
336 | typ->type = V_ASN1_UNDEF; | - | ||||||||||||
337 | } executed 700 times by 7 tests: end of block Executed by:
| 700 | ||||||||||||
338 | *pval = (ASN1_VALUE *)typ; | - | ||||||||||||
339 | break; executed 700 times by 7 tests: break; Executed by:
| 700 | ||||||||||||
340 | - | |||||||||||||
341 | default: executed 6326 times by 11 tests: default: Executed by:
| 6326 | ||||||||||||
342 | str = ASN1_STRING_type_new(utype); | - | ||||||||||||
343 | if (it != NULL && it->itype == ASN1_ITYPE_MSTRING &&
| 0-6326 | ||||||||||||
344 | str != NULL)
| 0-4265 | ||||||||||||
345 | str->flags |= ASN1_STRING_FLAG_MSTRING; executed 4265 times by 10 tests: str->flags |= 0x040; Executed by:
| 4265 | ||||||||||||
346 | *pval = (ASN1_VALUE *)str; | - | ||||||||||||
347 | break; executed 6326 times by 11 tests: break; Executed by:
| 6326 | ||||||||||||
348 | } | - | ||||||||||||
349 | if (*pval)
| 0-7026 | ||||||||||||
350 | return 1; executed 7026 times by 11 tests: return 1; Executed by:
| 7026 | ||||||||||||
351 | return 0; never executed: return 0; | 0 | ||||||||||||
352 | } | - | ||||||||||||
353 | - | |||||||||||||
354 | static void | - | ||||||||||||
355 | asn1_primitive_clear(ASN1_VALUE **pval, const ASN1_ITEM *it) | - | ||||||||||||
356 | { | - | ||||||||||||
357 | int utype; | - | ||||||||||||
358 | if (it && it->funcs) {
| 0-2843 | ||||||||||||
359 | const ASN1_PRIMITIVE_FUNCS *pf = it->funcs; | - | ||||||||||||
360 | if (pf->prim_clear)
| 0 | ||||||||||||
361 | pf->prim_clear(pval, it); never executed: pf->prim_clear(pval, it); | 0 | ||||||||||||
362 | else | - | ||||||||||||
363 | *pval = NULL; never executed: *pval = ((void *)0) ; | 0 | ||||||||||||
364 | return; never executed: return; | 0 | ||||||||||||
365 | } | - | ||||||||||||
366 | if (!it || (it->itype == ASN1_ITYPE_MSTRING))
| 0-2843 | ||||||||||||
367 | utype = V_ASN1_UNDEF; never executed: utype = -1; | 0 | ||||||||||||
368 | else | - | ||||||||||||
369 | utype = it->utype; executed 2843 times by 8 tests: utype = it->utype; Executed by:
| 2843 | ||||||||||||
370 | if (utype == V_ASN1_BOOLEAN)
| 945-1898 | ||||||||||||
371 | *(ASN1_BOOLEAN *)pval = it->size; executed 945 times by 8 tests: *(ASN1_BOOLEAN *)pval = it->size; Executed by:
| 945 | ||||||||||||
372 | else | - | ||||||||||||
373 | *pval = NULL; executed 1898 times by 8 tests: *pval = ((void *)0) ; Executed by:
| 1898 | ||||||||||||
374 | } | - | ||||||||||||
Source code | Switch to Preprocessed file |