Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/asn1/tasn_new.c |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /* | - | ||||||||||||
2 | * Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved. | - | ||||||||||||
3 | * | - | ||||||||||||
4 | * Licensed under the OpenSSL license (the "License"). You may not use | - | ||||||||||||
5 | * this file except in compliance with the License. You can obtain a copy | - | ||||||||||||
6 | * in the file LICENSE in the source distribution or at | - | ||||||||||||
7 | * https://www.openssl.org/source/license.html | - | ||||||||||||
8 | */ | - | ||||||||||||
9 | - | |||||||||||||
10 | #include <stddef.h> | - | ||||||||||||
11 | #include <openssl/asn1.h> | - | ||||||||||||
12 | #include <openssl/objects.h> | - | ||||||||||||
13 | #include <openssl/err.h> | - | ||||||||||||
14 | #include <openssl/asn1t.h> | - | ||||||||||||
15 | #include <string.h> | - | ||||||||||||
16 | #include "asn1_locl.h" | - | ||||||||||||
17 | - | |||||||||||||
18 | static int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, | - | ||||||||||||
19 | int embed); | - | ||||||||||||
20 | static int asn1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it, | - | ||||||||||||
21 | int embed); | - | ||||||||||||
22 | static void asn1_item_clear(ASN1_VALUE **pval, const ASN1_ITEM *it); | - | ||||||||||||
23 | static int asn1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); | - | ||||||||||||
24 | static void asn1_template_clear(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); | - | ||||||||||||
25 | static void asn1_primitive_clear(ASN1_VALUE **pval, const ASN1_ITEM *it); | - | ||||||||||||
26 | - | |||||||||||||
27 | ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it) | - | ||||||||||||
28 | { | - | ||||||||||||
29 | ASN1_VALUE *ret = NULL; | - | ||||||||||||
30 | if (ASN1_item_ex_new(&ret, it) > 0)
| 0-368142 | ||||||||||||
31 | return ret; executed 368142 times by 1 test: return ret; Executed by:
| 368142 | ||||||||||||
32 | return NULL; never executed: return ((void *)0) ; | 0 | ||||||||||||
33 | } | - | ||||||||||||
34 | - | |||||||||||||
35 | /* Allocate an ASN1 structure */ | - | ||||||||||||
36 | - | |||||||||||||
37 | int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it) | - | ||||||||||||
38 | { | - | ||||||||||||
39 | return asn1_item_embed_new(pval, it, 0); executed 1520094 times by 2 tests: return asn1_item_embed_new(pval, it, 0); Executed by:
| 1520094 | ||||||||||||
40 | } | - | ||||||||||||
41 | - | |||||||||||||
42 | int asn1_item_embed_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed) | - | ||||||||||||
43 | { | - | ||||||||||||
44 | const ASN1_TEMPLATE *tt = NULL; | - | ||||||||||||
45 | const ASN1_EXTERN_FUNCS *ef; | - | ||||||||||||
46 | const ASN1_AUX *aux = it->funcs; | - | ||||||||||||
47 | ASN1_aux_cb *asn1_cb; | - | ||||||||||||
48 | ASN1_VALUE **pseqval; | - | ||||||||||||
49 | int i; | - | ||||||||||||
50 | if (aux && aux->asn1_cb)
| 196852-3886273 | ||||||||||||
51 | asn1_cb = aux->asn1_cb; executed 440704 times by 2 tests: asn1_cb = aux->asn1_cb; Executed by:
| 440704 | ||||||||||||
52 | else | - | ||||||||||||
53 | asn1_cb = 0; executed 4083125 times by 2 tests: asn1_cb = 0; Executed by:
| 4083125 | ||||||||||||
54 | - | |||||||||||||
55 | #ifndef OPENSSL_NO_CRYPTO_MDEBUG | - | ||||||||||||
56 | OPENSSL_mem_debug_push(it->sname ? it->sname : "asn1_item_embed_new"); | - | ||||||||||||
57 | #endif | - | ||||||||||||
58 | - | |||||||||||||
59 | switch (it->itype) { | - | ||||||||||||
60 | - | |||||||||||||
61 | case ASN1_ITYPE_EXTERN: executed 151109 times by 1 test: case 0x4: Executed by:
| 151109 | ||||||||||||
62 | ef = it->funcs; | - | ||||||||||||
63 | if (ef && ef->asn1_ex_new) {
| 0-151109 | ||||||||||||
64 | if (!ef->asn1_ex_new(pval, it))
| 0-151109 | ||||||||||||
65 | goto memerr; never executed: goto memerr; | 0 | ||||||||||||
66 | } executed 151109 times by 1 test: end of block Executed by:
| 151109 | ||||||||||||
67 | break; executed 151109 times by 1 test: break; Executed by:
| 151109 | ||||||||||||
68 | - | |||||||||||||
69 | case ASN1_ITYPE_PRIMITIVE: executed 2016582 times by 2 tests: case 0x0: Executed by:
| 2016582 | ||||||||||||
70 | if (it->templates) {
| 1-2016581 | ||||||||||||
71 | if (!asn1_template_new(pval, it->templates))
| 0-1 | ||||||||||||
72 | goto memerr; never executed: goto memerr; | 0 | ||||||||||||
73 | } else if (!asn1_primitive_new(pval, it, embed)) executed 1 time by 1 test: end of block Executed by:
| 0-2016581 | ||||||||||||
74 | goto memerr; never executed: goto memerr; | 0 | ||||||||||||
75 | break; executed 2016582 times by 2 tests: break; Executed by:
| 2016582 | ||||||||||||
76 | - | |||||||||||||
77 | case ASN1_ITYPE_MSTRING: executed 427413 times by 1 test: case 0x5: Executed by:
| 427413 | ||||||||||||
78 | if (!asn1_primitive_new(pval, it, embed))
| 0-427413 | ||||||||||||
79 | goto memerr; never executed: goto memerr; | 0 | ||||||||||||
80 | break; executed 427413 times by 1 test: break; Executed by:
| 427413 | ||||||||||||
81 | - | |||||||||||||
82 | case ASN1_ITYPE_CHOICE: executed 221755 times by 1 test: case 0x2: Executed by:
| 221755 | ||||||||||||
83 | if (asn1_cb) {
| 32587-189168 | ||||||||||||
84 | i = asn1_cb(ASN1_OP_NEW_PRE, pval, it, NULL); | - | ||||||||||||
85 | if (!i)
| 0-32587 | ||||||||||||
86 | goto auxerr; never executed: goto auxerr; | 0 | ||||||||||||
87 | if (i == 2) {
| 0-32587 | ||||||||||||
88 | #ifndef OPENSSL_NO_CRYPTO_MDEBUG | - | ||||||||||||
89 | OPENSSL_mem_debug_pop(); | - | ||||||||||||
90 | #endif | - | ||||||||||||
91 | return 1; never executed: return 1; | 0 | ||||||||||||
92 | } | - | ||||||||||||
93 | } executed 32587 times by 1 test: end of block Executed by:
| 32587 | ||||||||||||
94 | if (embed) {
| 5986-215769 | ||||||||||||
95 | memset(*pval, 0, it->size); | - | ||||||||||||
96 | } else { executed 5986 times by 1 test: end of block Executed by:
| 5986 | ||||||||||||
97 | *pval = OPENSSL_zalloc(it->size); | - | ||||||||||||
98 | if (*pval == NULL)
| 0-215769 | ||||||||||||
99 | goto memerr; never executed: goto memerr; | 0 | ||||||||||||
100 | } executed 215769 times by 1 test: end of block Executed by:
| 215769 | ||||||||||||
101 | asn1_set_choice_selector(pval, -1, it); | - | ||||||||||||
102 | if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL))
| 0-189168 | ||||||||||||
103 | goto auxerr2; never executed: goto auxerr2; | 0 | ||||||||||||
104 | break; executed 221755 times by 1 test: break; Executed by:
| 221755 | ||||||||||||
105 | - | |||||||||||||
106 | case ASN1_ITYPE_NDEF_SEQUENCE: executed 50927 times by 1 test: case 0x6: Executed by:
| 50927 | ||||||||||||
107 | case ASN1_ITYPE_SEQUENCE: executed 1656043 times by 2 tests: case 0x1: Executed by:
| 1656043 | ||||||||||||
108 | if (asn1_cb) {
| 312615-1394355 | ||||||||||||
109 | i = asn1_cb(ASN1_OP_NEW_PRE, pval, it, NULL); | - | ||||||||||||
110 | if (!i)
| 0-312615 | ||||||||||||
111 | goto auxerr; never executed: goto auxerr; | 0 | ||||||||||||
112 | if (i == 2) {
| 46982-265633 | ||||||||||||
113 | #ifndef OPENSSL_NO_CRYPTO_MDEBUG | - | ||||||||||||
114 | OPENSSL_mem_debug_pop(); | - | ||||||||||||
115 | #endif | - | ||||||||||||
116 | return 1; executed 46982 times by 1 test: return 1; Executed by:
| 46982 | ||||||||||||
117 | } | - | ||||||||||||
118 | } executed 265633 times by 1 test: end of block Executed by:
| 265633 | ||||||||||||
119 | if (embed) {
| 312117-1347871 | ||||||||||||
120 | memset(*pval, 0, it->size); | - | ||||||||||||
121 | } else { executed 312117 times by 1 test: end of block Executed by:
| 312117 | ||||||||||||
122 | *pval = OPENSSL_zalloc(it->size); | - | ||||||||||||
123 | if (*pval == NULL)
| 0-1347871 | ||||||||||||
124 | goto memerr; never executed: goto memerr; | 0 | ||||||||||||
125 | } executed 1347871 times by 2 tests: end of block Executed by:
| 1347871 | ||||||||||||
126 | /* 0 : init. lock */ | - | ||||||||||||
127 | if (asn1_do_lock(pval, 0, it) < 0) {
| 0-1659988 | ||||||||||||
128 | if (!embed) {
| 0 | ||||||||||||
129 | OPENSSL_free(*pval); | - | ||||||||||||
130 | *pval = NULL; | - | ||||||||||||
131 | } never executed: end of block | 0 | ||||||||||||
132 | goto memerr; never executed: goto memerr; | 0 | ||||||||||||
133 | } | - | ||||||||||||
134 | asn1_enc_init(pval, it); | - | ||||||||||||
135 | for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) {
| 1659988-4864787 | ||||||||||||
136 | pseqval = asn1_get_field_ptr(pval, tt); | - | ||||||||||||
137 | if (!asn1_template_new(pseqval, tt))
| 0-4864787 | ||||||||||||
138 | goto memerr2; never executed: goto memerr2; | 0 | ||||||||||||
139 | } executed 4864787 times by 2 tests: end of block Executed by:
| 4864787 | ||||||||||||
140 | if (asn1_cb && !asn1_cb(ASN1_OP_NEW_POST, pval, it, NULL))
| 0-1394355 | ||||||||||||
141 | goto auxerr2; never executed: goto auxerr2; | 0 | ||||||||||||
142 | break; executed 1659988 times by 2 tests: break; Executed by:
| 1659988 | ||||||||||||
143 | } | - | ||||||||||||
144 | #ifndef OPENSSL_NO_CRYPTO_MDEBUG | - | ||||||||||||
145 | OPENSSL_mem_debug_pop(); | - | ||||||||||||
146 | #endif | - | ||||||||||||
147 | return 1; executed 4476847 times by 2 tests: return 1; Executed by:
| 4476847 | ||||||||||||
148 | - | |||||||||||||
149 | memerr2: | - | ||||||||||||
150 | asn1_item_embed_free(pval, it, embed); | - | ||||||||||||
151 | memerr: code before this statement never executed: memerr: | 0 | ||||||||||||
152 | ASN1err(ASN1_F_ASN1_ITEM_EMBED_NEW, ERR_R_MALLOC_FAILURE); | - | ||||||||||||
153 | #ifndef OPENSSL_NO_CRYPTO_MDEBUG | - | ||||||||||||
154 | OPENSSL_mem_debug_pop(); | - | ||||||||||||
155 | #endif | - | ||||||||||||
156 | return 0; never executed: return 0; | 0 | ||||||||||||
157 | - | |||||||||||||
158 | auxerr2: | - | ||||||||||||
159 | asn1_item_embed_free(pval, it, embed); | - | ||||||||||||
160 | auxerr: code before this statement never executed: auxerr: | 0 | ||||||||||||
161 | ASN1err(ASN1_F_ASN1_ITEM_EMBED_NEW, ASN1_R_AUX_ERROR); | - | ||||||||||||
162 | #ifndef OPENSSL_NO_CRYPTO_MDEBUG | - | ||||||||||||
163 | OPENSSL_mem_debug_pop(); | - | ||||||||||||
164 | #endif | - | ||||||||||||
165 | return 0; never executed: return 0; | 0 | ||||||||||||
166 | - | |||||||||||||
167 | } | - | ||||||||||||
168 | - | |||||||||||||
169 | static void asn1_item_clear(ASN1_VALUE **pval, const ASN1_ITEM *it) | - | ||||||||||||
170 | { | - | ||||||||||||
171 | const ASN1_EXTERN_FUNCS *ef; | - | ||||||||||||
172 | - | |||||||||||||
173 | switch (it->itype) { | - | ||||||||||||
174 | - | |||||||||||||
175 | case ASN1_ITYPE_EXTERN: never executed: case 0x4: | 0 | ||||||||||||
176 | ef = it->funcs; | - | ||||||||||||
177 | if (ef && ef->asn1_ex_clear)
| 0 | ||||||||||||
178 | ef->asn1_ex_clear(pval, it); never executed: ef->asn1_ex_clear(pval, it); | 0 | ||||||||||||
179 | else | - | ||||||||||||
180 | *pval = NULL; never executed: *pval = ((void *)0) ; | 0 | ||||||||||||
181 | break; never executed: break; | 0 | ||||||||||||
182 | - | |||||||||||||
183 | case ASN1_ITYPE_PRIMITIVE: executed 1252222 times by 1 test: case 0x0: Executed by:
| 1252222 | ||||||||||||
184 | if (it->templates)
| 0-1252222 | ||||||||||||
185 | asn1_template_clear(pval, it->templates); never executed: asn1_template_clear(pval, it->templates); | 0 | ||||||||||||
186 | else | - | ||||||||||||
187 | asn1_primitive_clear(pval, it); executed 1252222 times by 1 test: asn1_primitive_clear(pval, it); Executed by:
| 1252222 | ||||||||||||
188 | break; executed 1252222 times by 1 test: break; Executed by:
| 1252222 | ||||||||||||
189 | - | |||||||||||||
190 | case ASN1_ITYPE_MSTRING: executed 67411 times by 1 test: case 0x5: Executed by:
| 67411 | ||||||||||||
191 | asn1_primitive_clear(pval, it); | - | ||||||||||||
192 | break; executed 67411 times by 1 test: break; Executed by:
| 67411 | ||||||||||||
193 | - | |||||||||||||
194 | case ASN1_ITYPE_CHOICE: executed 75605 times by 1 test: case 0x2: Executed by:
| 75605 | ||||||||||||
195 | case ASN1_ITYPE_SEQUENCE: executed 52755 times by 1 test: case 0x1: Executed by:
| 52755 | ||||||||||||
196 | case ASN1_ITYPE_NDEF_SEQUENCE: executed 2962 times by 1 test: case 0x6: Executed by:
| 2962 | ||||||||||||
197 | *pval = NULL; | - | ||||||||||||
198 | break; executed 131322 times by 1 test: break; Executed by:
| 131322 | ||||||||||||
199 | } | - | ||||||||||||
200 | } executed 1450955 times by 1 test: end of block Executed by:
| 1450955 | ||||||||||||
201 | - | |||||||||||||
202 | static int asn1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) | - | ||||||||||||
203 | { | - | ||||||||||||
204 | const ASN1_ITEM *it = ASN1_ITEM_ptr(tt->item); | - | ||||||||||||
205 | int embed = tt->flags & ASN1_TFLG_EMBED; | - | ||||||||||||
206 | ASN1_VALUE *tval; | - | ||||||||||||
207 | int ret; | - | ||||||||||||
208 | if (embed) {
| 772994-4091794 | ||||||||||||
209 | tval = (ASN1_VALUE *)pval; | - | ||||||||||||
210 | pval = &tval; | - | ||||||||||||
211 | } executed 772994 times by 1 test: end of block Executed by:
| 772994 | ||||||||||||
212 | if (tt->flags & ASN1_TFLG_OPTIONAL) {
| 1745970-3118818 | ||||||||||||
213 | asn1_template_clear(pval, tt); | - | ||||||||||||
214 | return 1; executed 1745970 times by 1 test: return 1; Executed by:
| 1745970 | ||||||||||||
215 | } | - | ||||||||||||
216 | /* If ANY DEFINED BY nothing to do */ | - | ||||||||||||
217 | - | |||||||||||||
218 | if (tt->flags & ASN1_TFLG_ADB_MASK) {
| 48005-3070813 | ||||||||||||
219 | *pval = NULL; | - | ||||||||||||
220 | return 1; executed 48005 times by 1 test: return 1; Executed by:
| 48005 | ||||||||||||
221 | } | - | ||||||||||||
222 | #ifndef OPENSSL_NO_CRYPTO_MDEBUG | - | ||||||||||||
223 | OPENSSL_mem_debug_push(tt->field_name | - | ||||||||||||
224 | ? tt->field_name : "asn1_template_new"); | - | ||||||||||||
225 | #endif | - | ||||||||||||
226 | /* If SET OF or SEQUENCE OF, its a STACK */ | - | ||||||||||||
227 | if (tt->flags & ASN1_TFLG_SK_MASK) {
| 67078-3003735 | ||||||||||||
228 | STACK_OF(ASN1_VALUE) *skval; | - | ||||||||||||
229 | skval = sk_ASN1_VALUE_new_null(); | - | ||||||||||||
230 | if (!skval) {
| 0-67078 | ||||||||||||
231 | ASN1err(ASN1_F_ASN1_TEMPLATE_NEW, ERR_R_MALLOC_FAILURE); | - | ||||||||||||
232 | ret = 0; | - | ||||||||||||
233 | goto done; never executed: goto done; | 0 | ||||||||||||
234 | } | - | ||||||||||||
235 | *pval = (ASN1_VALUE *)skval; | - | ||||||||||||
236 | ret = 1; | - | ||||||||||||
237 | goto done; executed 67078 times by 1 test: goto done; Executed by:
| 67078 | ||||||||||||
238 | } | - | ||||||||||||
239 | /* Otherwise pass it back to the item routine */ | - | ||||||||||||
240 | ret = asn1_item_embed_new(pval, it, embed); | - | ||||||||||||
241 | done: code before this statement executed 3003735 times by 2 tests: done: Executed by:
| 3003735 | ||||||||||||
242 | #ifndef OPENSSL_NO_CRYPTO_MDEBUG | - | ||||||||||||
243 | OPENSSL_mem_debug_pop(); | - | ||||||||||||
244 | #endif | - | ||||||||||||
245 | return ret; executed 3070813 times by 2 tests: return ret; Executed by:
| 3070813 | ||||||||||||
246 | } | - | ||||||||||||
247 | - | |||||||||||||
248 | static void asn1_template_clear(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) | - | ||||||||||||
249 | { | - | ||||||||||||
250 | /* If ADB or STACK just NULL the field */ | - | ||||||||||||
251 | if (tt->flags & (ASN1_TFLG_ADB_MASK | ASN1_TFLG_SK_MASK))
| 295015-1450955 | ||||||||||||
252 | *pval = NULL; executed 295015 times by 1 test: *pval = ((void *)0) ; Executed by:
| 295015 | ||||||||||||
253 | else | - | ||||||||||||
254 | asn1_item_clear(pval, ASN1_ITEM_ptr(tt->item)); executed 1450955 times by 1 test: asn1_item_clear(pval, (tt->item)); Executed by:
| 1450955 | ||||||||||||
255 | } | - | ||||||||||||
256 | - | |||||||||||||
257 | /* | - | ||||||||||||
258 | * NB: could probably combine most of the real XXX_new() behaviour and junk | - | ||||||||||||
259 | * all the old functions. | - | ||||||||||||
260 | */ | - | ||||||||||||
261 | - | |||||||||||||
262 | static int asn1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it, | - | ||||||||||||
263 | int embed) | - | ||||||||||||
264 | { | - | ||||||||||||
265 | ASN1_TYPE *typ; | - | ||||||||||||
266 | ASN1_STRING *str; | - | ||||||||||||
267 | int utype; | - | ||||||||||||
268 | - | |||||||||||||
269 | if (!it)
| 0-2443994 | ||||||||||||
270 | return 0; never executed: return 0; | 0 | ||||||||||||
271 | - | |||||||||||||
272 | if (it->funcs) {
| 95502-2348492 | ||||||||||||
273 | const ASN1_PRIMITIVE_FUNCS *pf = it->funcs; | - | ||||||||||||
274 | if (embed) {
| 41973-53529 | ||||||||||||
275 | if (pf->prim_clear) {
| 0-41973 | ||||||||||||
276 | pf->prim_clear(pval, it); | - | ||||||||||||
277 | return 1; executed 41973 times by 1 test: return 1; Executed by:
| 41973 | ||||||||||||
278 | } | - | ||||||||||||
279 | } else if (pf->prim_new) { never executed: end of block
| 0-53529 | ||||||||||||
280 | return pf->prim_new(pval, it); executed 53529 times by 2 tests: return pf->prim_new(pval, it); Executed by:
| 53529 | ||||||||||||
281 | } | - | ||||||||||||
282 | } never executed: end of block | 0 | ||||||||||||
283 | - | |||||||||||||
284 | if (it->itype == ASN1_ITYPE_MSTRING)
| 427413-1921079 | ||||||||||||
285 | utype = -1; executed 427413 times by 1 test: utype = -1; Executed by:
| 427413 | ||||||||||||
286 | else | - | ||||||||||||
287 | utype = it->utype; executed 1921079 times by 2 tests: utype = it->utype; Executed by:
| 1921079 | ||||||||||||
288 | switch (utype) { | - | ||||||||||||
289 | case V_ASN1_OBJECT: executed 933921 times by 1 test: case 6: Executed by:
| 933921 | ||||||||||||
290 | *pval = (ASN1_VALUE *)OBJ_nid2obj(NID_undef); | - | ||||||||||||
291 | return 1; executed 933921 times by 1 test: return 1; Executed by:
| 933921 | ||||||||||||
292 | - | |||||||||||||
293 | case V_ASN1_BOOLEAN: executed 232 times by 1 test: case 1: Executed by:
| 232 | ||||||||||||
294 | *(ASN1_BOOLEAN *)pval = it->size; | - | ||||||||||||
295 | return 1; executed 232 times by 1 test: return 1; Executed by:
| 232 | ||||||||||||
296 | - | |||||||||||||
297 | case V_ASN1_NULL: executed 2 times by 1 test: case 5: Executed by:
| 2 | ||||||||||||
298 | *pval = (ASN1_VALUE *)1; | - | ||||||||||||
299 | return 1; executed 2 times by 1 test: return 1; Executed by:
| 2 | ||||||||||||
300 | - | |||||||||||||
301 | case V_ASN1_ANY: executed 237207 times by 1 test: case -4: Executed by:
| 237207 | ||||||||||||
302 | if ((typ = OPENSSL_malloc(sizeof(*typ))) == NULL) {
| 0-237207 | ||||||||||||
303 | ASN1err(ASN1_F_ASN1_PRIMITIVE_NEW, ERR_R_MALLOC_FAILURE); | - | ||||||||||||
304 | return 0; never executed: return 0; | 0 | ||||||||||||
305 | } | - | ||||||||||||
306 | typ->value.ptr = NULL; | - | ||||||||||||
307 | typ->type = -1; | - | ||||||||||||
308 | *pval = (ASN1_VALUE *)typ; | - | ||||||||||||
309 | break; executed 237207 times by 1 test: break; Executed by:
| 237207 | ||||||||||||
310 | - | |||||||||||||
311 | default: executed 1177130 times by 2 tests: default: Executed by:
| 1177130 | ||||||||||||
312 | if (embed) {
| 373108-804022 | ||||||||||||
313 | str = *(ASN1_STRING **)pval; | - | ||||||||||||
314 | memset(str, 0, sizeof(*str)); | - | ||||||||||||
315 | str->type = utype; | - | ||||||||||||
316 | str->flags = ASN1_STRING_FLAG_EMBED; | - | ||||||||||||
317 | } else { executed 373108 times by 1 test: end of block Executed by:
| 373108 | ||||||||||||
318 | str = ASN1_STRING_type_new(utype); | - | ||||||||||||
319 | *pval = (ASN1_VALUE *)str; | - | ||||||||||||
320 | } executed 804022 times by 2 tests: end of block Executed by:
| 804022 | ||||||||||||
321 | if (it->itype == ASN1_ITYPE_MSTRING && str)
| 0-749717 | ||||||||||||
322 | str->flags |= ASN1_STRING_FLAG_MSTRING; executed 427413 times by 1 test: str->flags |= 0x040; Executed by:
| 427413 | ||||||||||||
323 | break; executed 1177130 times by 2 tests: break; Executed by:
| 1177130 | ||||||||||||
324 | } | - | ||||||||||||
325 | if (*pval)
| 0-1414337 | ||||||||||||
326 | return 1; executed 1414337 times by 2 tests: return 1; Executed by:
| 1414337 | ||||||||||||
327 | return 0; never executed: return 0; | 0 | ||||||||||||
328 | } | - | ||||||||||||
329 | - | |||||||||||||
330 | static void asn1_primitive_clear(ASN1_VALUE **pval, const ASN1_ITEM *it) | - | ||||||||||||
331 | { | - | ||||||||||||
332 | int utype; | - | ||||||||||||
333 | if (it && it->funcs) {
| 0-1319633 | ||||||||||||
334 | const ASN1_PRIMITIVE_FUNCS *pf = it->funcs; | - | ||||||||||||
335 | if (pf->prim_clear)
| 5145-39856 | ||||||||||||
336 | pf->prim_clear(pval, it); executed 39856 times by 1 test: pf->prim_clear(pval, it); Executed by:
| 39856 | ||||||||||||
337 | else | - | ||||||||||||
338 | *pval = NULL; executed 5145 times by 1 test: *pval = ((void *)0) ; Executed by:
| 5145 | ||||||||||||
339 | return; executed 45001 times by 1 test: return; Executed by:
| 45001 | ||||||||||||
340 | } | - | ||||||||||||
341 | if (!it || (it->itype == ASN1_ITYPE_MSTRING))
| 0-1274632 | ||||||||||||
342 | utype = -1; executed 67411 times by 1 test: utype = -1; Executed by:
| 67411 | ||||||||||||
343 | else | - | ||||||||||||
344 | utype = it->utype; executed 1207221 times by 1 test: utype = it->utype; Executed by:
| 1207221 | ||||||||||||
345 | if (utype == V_ASN1_BOOLEAN)
| 367682-906950 | ||||||||||||
346 | *(ASN1_BOOLEAN *)pval = it->size; executed 367682 times by 1 test: *(ASN1_BOOLEAN *)pval = it->size; Executed by:
| 367682 | ||||||||||||
347 | else | - | ||||||||||||
348 | *pval = NULL; executed 906950 times by 1 test: *pval = ((void *)0) ; Executed by:
| 906950 | ||||||||||||
349 | } | - | ||||||||||||
Source code | Switch to Preprocessed file |