Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/asn1/tasn_dec.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||||||||
2 | - | |||||||||||||||||||||||||
3 | - | |||||||||||||||||||||||||
4 | - | |||||||||||||||||||||||||
5 | - | |||||||||||||||||||||||||
6 | - | |||||||||||||||||||||||||
7 | - | |||||||||||||||||||||||||
8 | static int asn1_check_eoc(const unsigned char **in, long len); | - | ||||||||||||||||||||||||
9 | static int asn1_find_end(const unsigned char **in, long len, char inf); | - | ||||||||||||||||||||||||
10 | - | |||||||||||||||||||||||||
11 | static int asn1_collect(BUF_MEM *buf, const unsigned char **in, long len, | - | ||||||||||||||||||||||||
12 | char inf, int tag, int aclass, int depth); | - | ||||||||||||||||||||||||
13 | - | |||||||||||||||||||||||||
14 | static int collect_data(BUF_MEM *buf, const unsigned char **p, long plen); | - | ||||||||||||||||||||||||
15 | - | |||||||||||||||||||||||||
16 | static int asn1_check_tlen(long *olen, int *otag, unsigned char *oclass, | - | ||||||||||||||||||||||||
17 | char *inf, char *cst, const unsigned char **in, long len, int exptag, | - | ||||||||||||||||||||||||
18 | int expclass, char opt, ASN1_TLC *ctx); | - | ||||||||||||||||||||||||
19 | - | |||||||||||||||||||||||||
20 | static int asn1_template_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, | - | ||||||||||||||||||||||||
21 | long len, const ASN1_TEMPLATE *tt, char opt, ASN1_TLC *ctx, int depth); | - | ||||||||||||||||||||||||
22 | static int asn1_template_noexp_d2i(ASN1_VALUE **val, const unsigned char **in, | - | ||||||||||||||||||||||||
23 | long len, const ASN1_TEMPLATE *tt, char opt, ASN1_TLC *ctx, int depth); | - | ||||||||||||||||||||||||
24 | static int asn1_d2i_ex_primitive(ASN1_VALUE **pval, const unsigned char **in, | - | ||||||||||||||||||||||||
25 | long len, const ASN1_ITEM *it, int tag, int aclass, char opt, | - | ||||||||||||||||||||||||
26 | ASN1_TLC *ctx); | - | ||||||||||||||||||||||||
27 | - | |||||||||||||||||||||||||
28 | - | |||||||||||||||||||||||||
29 | static const unsigned long tag2bit[32] = { | - | ||||||||||||||||||||||||
30 | 0, 0, 0, 0x0400, | - | ||||||||||||||||||||||||
31 | 0x0200, 0, 0, 0x1000, | - | ||||||||||||||||||||||||
32 | 0x1000, 0x1000, 0x1000, 0x1000, | - | ||||||||||||||||||||||||
33 | 0x2000,0x1000,0x1000,0x1000, | - | ||||||||||||||||||||||||
34 | 0x10000,0,0x0001,0x0002, | - | ||||||||||||||||||||||||
35 | 0x0004,0x0008,0x0010, | - | ||||||||||||||||||||||||
36 | 0x4000, 0x8000, | - | ||||||||||||||||||||||||
37 | 0x0020,0x0040,0x0080, | - | ||||||||||||||||||||||||
38 | 0x0100,0x1000,0x0800,0x1000, | - | ||||||||||||||||||||||||
39 | }; | - | ||||||||||||||||||||||||
40 | - | |||||||||||||||||||||||||
41 | unsigned long | - | ||||||||||||||||||||||||
42 | ASN1_tag2bit(int tag) | - | ||||||||||||||||||||||||
43 | { | - | ||||||||||||||||||||||||
44 | if ((
| 0-4114 | ||||||||||||||||||||||||
45 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
46 | return executed 4114 times by 8 tests: tag2bit[tag];return tag2bit[tag]; Executed by:
executed 4114 times by 8 tests: return tag2bit[tag]; Executed by:
| 4114 | ||||||||||||||||||||||||
47 | } | - | ||||||||||||||||||||||||
48 | ASN1_VALUE * | - | ||||||||||||||||||||||||
49 | ASN1_item_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, | - | ||||||||||||||||||||||||
50 | const ASN1_ITEM *it) | - | ||||||||||||||||||||||||
51 | { | - | ||||||||||||||||||||||||
52 | ASN1_TLC c; | - | ||||||||||||||||||||||||
53 | ASN1_VALUE *ptmpval = | - | ||||||||||||||||||||||||
54 | ((void *)0) | - | ||||||||||||||||||||||||
55 | ; | - | ||||||||||||||||||||||||
56 | - | |||||||||||||||||||||||||
57 | if (!pval
| 512-1275 | ||||||||||||||||||||||||
58 | pval = &ptmpval; executed 1275 times by 10 tests: pval = &ptmpval; Executed by:
| 1275 | ||||||||||||||||||||||||
59 | (&c)->valid = 0; | - | ||||||||||||||||||||||||
60 | if (ASN1_item_ex_d2i(pval, in, len, it, -1, 0, 0, &c) > 0
| 76-1711 | ||||||||||||||||||||||||
61 | return executed 1711 times by 12 tests: *pval;return *pval; Executed by:
executed 1711 times by 12 tests: return *pval; Executed by:
| 1711 | ||||||||||||||||||||||||
62 | return executed 76 times by 1 test: return ((void *)0) ; Executed by:
executed 76 times by 1 test: return ((void *)0) ; Executed by:
| 76 | ||||||||||||||||||||||||
63 | ((void *)0) executed 76 times by 1 test: return ((void *)0) ; Executed by:
| 76 | ||||||||||||||||||||||||
64 | ; executed 76 times by 1 test: return ((void *)0) ; Executed by:
| 76 | ||||||||||||||||||||||||
65 | } | - | ||||||||||||||||||||||||
66 | - | |||||||||||||||||||||||||
67 | int | - | ||||||||||||||||||||||||
68 | ASN1_template_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, | - | ||||||||||||||||||||||||
69 | const ASN1_TEMPLATE *tt) | - | ||||||||||||||||||||||||
70 | { | - | ||||||||||||||||||||||||
71 | ASN1_TLC c; | - | ||||||||||||||||||||||||
72 | - | |||||||||||||||||||||||||
73 | (&c)->valid = 0; | - | ||||||||||||||||||||||||
74 | return never executed: asn1_template_ex_d2i(pval, in, len, tt, 0, &c, 0);return asn1_template_ex_d2i(pval, in, len, tt, 0, &c, 0); never executed: return asn1_template_ex_d2i(pval, in, len, tt, 0, &c, 0); | 0 | ||||||||||||||||||||||||
75 | } | - | ||||||||||||||||||||||||
76 | - | |||||||||||||||||||||||||
77 | - | |||||||||||||||||||||||||
78 | - | |||||||||||||||||||||||||
79 | - | |||||||||||||||||||||||||
80 | - | |||||||||||||||||||||||||
81 | - | |||||||||||||||||||||||||
82 | static int | - | ||||||||||||||||||||||||
83 | asn1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, | - | ||||||||||||||||||||||||
84 | const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx, | - | ||||||||||||||||||||||||
85 | int depth) | - | ||||||||||||||||||||||||
86 | { | - | ||||||||||||||||||||||||
87 | const ASN1_TEMPLATE *tt, *errtt = | - | ||||||||||||||||||||||||
88 | ((void *)0) | - | ||||||||||||||||||||||||
89 | ; | - | ||||||||||||||||||||||||
90 | const ASN1_EXTERN_FUNCS *ef; | - | ||||||||||||||||||||||||
91 | const ASN1_AUX *aux = it->funcs; | - | ||||||||||||||||||||||||
92 | ASN1_aux_cb *asn1_cb = | - | ||||||||||||||||||||||||
93 | ((void *)0) | - | ||||||||||||||||||||||||
94 | ; | - | ||||||||||||||||||||||||
95 | const unsigned char *p = | - | ||||||||||||||||||||||||
96 | ((void *)0) | - | ||||||||||||||||||||||||
97 | , *q; | - | ||||||||||||||||||||||||
98 | unsigned char oclass; | - | ||||||||||||||||||||||||
99 | char seq_eoc, seq_nolen, cst, isopt; | - | ||||||||||||||||||||||||
100 | long tmplen; | - | ||||||||||||||||||||||||
101 | int i; | - | ||||||||||||||||||||||||
102 | int otag; | - | ||||||||||||||||||||||||
103 | int ret = 0; | - | ||||||||||||||||||||||||
104 | ASN1_VALUE **pchptr; | - | ||||||||||||||||||||||||
105 | int combine; | - | ||||||||||||||||||||||||
106 | - | |||||||||||||||||||||||||
107 | combine = aclass & (0x1<<10); | - | ||||||||||||||||||||||||
108 | aclass &= ~(0x1<<10); | - | ||||||||||||||||||||||||
109 | - | |||||||||||||||||||||||||
110 | if (!pval
| 0-19822 | ||||||||||||||||||||||||
111 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
112 | - | |||||||||||||||||||||||||
113 | if (aux
| 692-16109 | ||||||||||||||||||||||||
114 | asn1_cb = aux->asn1_cb; executed 3021 times by 9 tests: asn1_cb = aux->asn1_cb; Executed by:
| 3021 | ||||||||||||||||||||||||
115 | - | |||||||||||||||||||||||||
116 | if (++
| 0-19822 | ||||||||||||||||||||||||
117 | ERR_put_error(13,(0xfff),(219),__FILE__,188); | - | ||||||||||||||||||||||||
118 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
119 | } | - | ||||||||||||||||||||||||
120 | - | |||||||||||||||||||||||||
121 | switch (it->itype) { | - | ||||||||||||||||||||||||
122 | case executed 11673 times by 12 tests: 0x0:case 0x0: Executed by:
executed 11673 times by 12 tests: case 0x0: Executed by:
| 11673 | ||||||||||||||||||||||||
123 | if (it->templates
| 2291-9382 | ||||||||||||||||||||||||
124 | - | |||||||||||||||||||||||||
125 | - | |||||||||||||||||||||||||
126 | - | |||||||||||||||||||||||||
127 | - | |||||||||||||||||||||||||
128 | - | |||||||||||||||||||||||||
129 | - | |||||||||||||||||||||||||
130 | if ((
| 0-2291 | ||||||||||||||||||||||||
131 | ERR_put_error(13,(0xfff),(170),__FILE__,202); | - | ||||||||||||||||||||||||
132 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
133 | } | - | ||||||||||||||||||||||||
134 | return executed 2291 times by 8 tests: asn1_template_ex_d2i(pval, in, len,return asn1_template_ex_d2i(pval, in, len, it->templates, opt, ctx, depth); Executed by:
executed 2291 times by 8 tests: return asn1_template_ex_d2i(pval, in, len, it->templates, opt, ctx, depth); Executed by:
| 2291 | ||||||||||||||||||||||||
135 | it->templates, opt, ctx, depth); executed 2291 times by 8 tests: return asn1_template_ex_d2i(pval, in, len, it->templates, opt, ctx, depth); Executed by:
| 2291 | ||||||||||||||||||||||||
136 | } | - | ||||||||||||||||||||||||
137 | return executed 9382 times by 12 tests: asn1_d2i_ex_primitive(pval, in, len, it,return asn1_d2i_ex_primitive(pval, in, len, it, tag, aclass, opt, ctx); Executed by:
executed 9382 times by 12 tests: return asn1_d2i_ex_primitive(pval, in, len, it, tag, aclass, opt, ctx); Executed by:
| 9382 | ||||||||||||||||||||||||
138 | tag, aclass, opt, ctx); executed 9382 times by 12 tests: return asn1_d2i_ex_primitive(pval, in, len, it, tag, aclass, opt, ctx); Executed by:
| 9382 | ||||||||||||||||||||||||
139 | break; dead code: break; | - | ||||||||||||||||||||||||
140 | - | |||||||||||||||||||||||||
141 | case executed 2276 times by 8 tests: 0x5:case 0x5: Executed by:
executed 2276 times by 8 tests: case 0x5: Executed by:
| 2276 | ||||||||||||||||||||||||
142 | p = *in; | - | ||||||||||||||||||||||||
143 | - | |||||||||||||||||||||||||
144 | ret = asn1_check_tlen( | - | ||||||||||||||||||||||||
145 | ((void *)0) | - | ||||||||||||||||||||||||
146 | , &otag, &oclass, | - | ||||||||||||||||||||||||
147 | ((void *)0) | - | ||||||||||||||||||||||||
148 | , | - | ||||||||||||||||||||||||
149 | ((void *)0) | - | ||||||||||||||||||||||||
150 | , | - | ||||||||||||||||||||||||
151 | &p, len, -1, 0, 1, ctx); | - | ||||||||||||||||||||||||
152 | if (!ret
| 0-2276 | ||||||||||||||||||||||||
153 | ERR_put_error(13,(0xfff),(58),__FILE__,218); | - | ||||||||||||||||||||||||
154 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
155 | } | - | ||||||||||||||||||||||||
156 | - | |||||||||||||||||||||||||
157 | - | |||||||||||||||||||||||||
158 | if (oclass != 0x00
| 0-2276 | ||||||||||||||||||||||||
159 | - | |||||||||||||||||||||||||
160 | if (opt
| 0 | ||||||||||||||||||||||||
161 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
162 | ERR_put_error(13,(0xfff),(139),__FILE__,227); | - | ||||||||||||||||||||||||
163 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
164 | } | - | ||||||||||||||||||||||||
165 | - | |||||||||||||||||||||||||
166 | if (!(ASN1_tag2bit(otag) & it->utype)
| 0-2276 | ||||||||||||||||||||||||
167 | - | |||||||||||||||||||||||||
168 | if (opt
| 0 | ||||||||||||||||||||||||
169 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
170 | ERR_put_error(13,(0xfff),(140),__FILE__,235); | - | ||||||||||||||||||||||||
171 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
172 | } | - | ||||||||||||||||||||||||
173 | return executed 2276 times by 8 tests: asn1_d2i_ex_primitive(pval, in, len,return asn1_d2i_ex_primitive(pval, in, len, it, otag, 0, 0, ctx); Executed by:
executed 2276 times by 8 tests: return asn1_d2i_ex_primitive(pval, in, len, it, otag, 0, 0, ctx); Executed by:
| 2276 | ||||||||||||||||||||||||
174 | it, otag, 0, 0, ctx); executed 2276 times by 8 tests: return asn1_d2i_ex_primitive(pval, in, len, it, otag, 0, 0, ctx); Executed by:
| 2276 | ||||||||||||||||||||||||
175 | - | |||||||||||||||||||||||||
176 | case executed 473 times by 8 tests: 0x4:case 0x4: Executed by:
executed 473 times by 8 tests: case 0x4: Executed by:
| 473 | ||||||||||||||||||||||||
177 | - | |||||||||||||||||||||||||
178 | ef = it->funcs; | - | ||||||||||||||||||||||||
179 | return executed 473 times by 8 tests: ef->asn1_ex_d2i(pval, in, len,return ef->asn1_ex_d2i(pval, in, len, it, tag, aclass, opt, ctx); Executed by:
executed 473 times by 8 tests: return ef->asn1_ex_d2i(pval, in, len, it, tag, aclass, opt, ctx); Executed by:
| 473 | ||||||||||||||||||||||||
180 | it, tag, aclass, opt, ctx); executed 473 times by 8 tests: return ef->asn1_ex_d2i(pval, in, len, it, tag, aclass, opt, ctx); Executed by:
| 473 | ||||||||||||||||||||||||
181 | - | |||||||||||||||||||||||||
182 | case executed 32 times by 2 tests: 0x2:case 0x2: Executed by:
executed 32 times by 2 tests: case 0x2: Executed by:
| 32 | ||||||||||||||||||||||||
183 | if (asn1_cb
| 0-32 | ||||||||||||||||||||||||
184 | ((void *)0)
| 0 | ||||||||||||||||||||||||
185 | )
| 0 | ||||||||||||||||||||||||
186 | goto never executed: auxerr;goto auxerr; never executed: goto auxerr; | 0 | ||||||||||||||||||||||||
187 | - | |||||||||||||||||||||||||
188 | if (*
| 8-24 | ||||||||||||||||||||||||
189 | - | |||||||||||||||||||||||||
190 | i = asn1_get_choice_selector(pval, it); | - | ||||||||||||||||||||||||
191 | if ((
| 0-8 | ||||||||||||||||||||||||
192 | tt = it->templates + i; | - | ||||||||||||||||||||||||
193 | pchptr = asn1_get_field_ptr(pval, tt); | - | ||||||||||||||||||||||||
194 | ASN1_template_free(pchptr, tt); | - | ||||||||||||||||||||||||
195 | asn1_set_choice_selector(pval, -1, it); | - | ||||||||||||||||||||||||
196 | } never executed: end of block | 0 | ||||||||||||||||||||||||
197 | } executed 8 times by 1 test: else if (!ASN1_item_ex_new(pval, it)end of block Executed by:
| 0-24 | ||||||||||||||||||||||||
198 | ERR_put_error(13,(0xfff),(58),__FILE__,261); | - | ||||||||||||||||||||||||
199 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
200 | } | - | ||||||||||||||||||||||||
201 | - | |||||||||||||||||||||||||
202 | p = *in; | - | ||||||||||||||||||||||||
203 | for (i = 0, tt = it->templates; i < it->tcount
| 0-90 | ||||||||||||||||||||||||
204 | pchptr = asn1_get_field_ptr(pval, tt); | - | ||||||||||||||||||||||||
205 | - | |||||||||||||||||||||||||
206 | - | |||||||||||||||||||||||||
207 | - | |||||||||||||||||||||||||
208 | ret = asn1_template_ex_d2i(pchptr, &p, len, tt, 1, ctx, | - | ||||||||||||||||||||||||
209 | depth); | - | ||||||||||||||||||||||||
210 | - | |||||||||||||||||||||||||
211 | if (ret == -1
| 32-58 | ||||||||||||||||||||||||
212 | continue; executed 58 times by 1 test: continue; Executed by:
| 58 | ||||||||||||||||||||||||
213 | - | |||||||||||||||||||||||||
214 | if (ret > 0
| 0-32 | ||||||||||||||||||||||||
215 | break; executed 32 times by 2 tests: break; Executed by:
| 32 | ||||||||||||||||||||||||
216 | - | |||||||||||||||||||||||||
217 | errtt = tt; | - | ||||||||||||||||||||||||
218 | ERR_put_error(13,(0xfff),(58),__FILE__,281); | - | ||||||||||||||||||||||||
219 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
220 | } | - | ||||||||||||||||||||||||
221 | - | |||||||||||||||||||||||||
222 | - | |||||||||||||||||||||||||
223 | if (i == it->tcount
| 0-32 | ||||||||||||||||||||||||
224 | - | |||||||||||||||||||||||||
225 | if (opt
| 0 | ||||||||||||||||||||||||
226 | - | |||||||||||||||||||||||||
227 | ASN1_item_ex_free(pval, it); | - | ||||||||||||||||||||||||
228 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||||||||||||||
229 | } | - | ||||||||||||||||||||||||
230 | ERR_put_error(13,(0xfff),(143),__FILE__,293); | - | ||||||||||||||||||||||||
231 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
232 | } | - | ||||||||||||||||||||||||
233 | - | |||||||||||||||||||||||||
234 | asn1_set_choice_selector(pval, i, it); | - | ||||||||||||||||||||||||
235 | *in = p; | - | ||||||||||||||||||||||||
236 | if (asn1_cb
| 0-32 | ||||||||||||||||||||||||
237 | ((void *)0)
| 0 | ||||||||||||||||||||||||
238 | )
| 0 | ||||||||||||||||||||||||
239 | goto never executed: auxerr;goto auxerr; never executed: goto auxerr; | 0 | ||||||||||||||||||||||||
240 | return executed 32 times by 2 tests: 1;return 1; Executed by:
executed 32 times by 2 tests: return 1; Executed by:
| 32 | ||||||||||||||||||||||||
241 | - | |||||||||||||||||||||||||
242 | case executed 9 times by 1 test: 0x6:case 0x6: Executed by:
executed 9 times by 1 test: case 0x6: Executed by:
| 9 | ||||||||||||||||||||||||
243 | case executed 5359 times by 11 tests: 0x1:case 0x1: Executed by:
executed 5359 times by 11 tests: case 0x1: Executed by:
| 5359 | ||||||||||||||||||||||||
244 | p = *in; | - | ||||||||||||||||||||||||
245 | tmplen = len; | - | ||||||||||||||||||||||||
246 | - | |||||||||||||||||||||||||
247 | - | |||||||||||||||||||||||||
248 | if (tag == -1
| 26-5342 | ||||||||||||||||||||||||
249 | tag = 16; | - | ||||||||||||||||||||||||
250 | aclass = 0x00; | - | ||||||||||||||||||||||||
251 | } executed 5342 times by 11 tests: end of block Executed by:
| 5342 | ||||||||||||||||||||||||
252 | - | |||||||||||||||||||||||||
253 | ret = asn1_check_tlen(&len, | - | ||||||||||||||||||||||||
254 | ((void *)0) | - | ||||||||||||||||||||||||
255 | , | - | ||||||||||||||||||||||||
256 | ((void *)0) | - | ||||||||||||||||||||||||
257 | , &seq_eoc, &cst, | - | ||||||||||||||||||||||||
258 | &p, len, tag, aclass, opt, ctx); | - | ||||||||||||||||||||||||
259 | if (!ret
| 76-5292 | ||||||||||||||||||||||||
260 | ERR_put_error(13,(0xfff),(58),__FILE__,317); | - | ||||||||||||||||||||||||
261 | goto executed 76 times by 1 test: err;goto err; Executed by:
executed 76 times by 1 test: goto err; Executed by:
| 76 | ||||||||||||||||||||||||
262 | } else if (ret == -1
| 26-5266 | ||||||||||||||||||||||||
263 | return executed 26 times by 1 test: -1;return -1; Executed by:
executed 26 times by 1 test: return -1; Executed by:
| 26 | ||||||||||||||||||||||||
264 | if (aux
| 0-4204 | ||||||||||||||||||||||||
265 | len = tmplen - (p - *in); | - | ||||||||||||||||||||||||
266 | seq_nolen = 1; | - | ||||||||||||||||||||||||
267 | } never executed: end of block | 0 | ||||||||||||||||||||||||
268 | - | |||||||||||||||||||||||||
269 | else | - | ||||||||||||||||||||||||
270 | seq_nolen = seq_eoc; executed 5266 times by 11 tests: seq_nolen = seq_eoc; Executed by:
| 5266 | ||||||||||||||||||||||||
271 | if (!cst
| 0-5266 | ||||||||||||||||||||||||
272 | ERR_put_error(13,(0xfff),(149),__FILE__,329); | - | ||||||||||||||||||||||||
273 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
274 | } | - | ||||||||||||||||||||||||
275 | - | |||||||||||||||||||||||||
276 | if (!*pval
| 0-3559 | ||||||||||||||||||||||||
277 | ERR_put_error(13,(0xfff),(58),__FILE__,334); | - | ||||||||||||||||||||||||
278 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
279 | } | - | ||||||||||||||||||||||||
280 | - | |||||||||||||||||||||||||
281 | if (asn1_cb
| 0-4423 | ||||||||||||||||||||||||
282 | ((void *)0)
| 0-843 | ||||||||||||||||||||||||
283 | )
| 0-843 | ||||||||||||||||||||||||
284 | goto never executed: auxerr;goto auxerr; never executed: goto auxerr; | 0 | ||||||||||||||||||||||||
285 | - | |||||||||||||||||||||||||
286 | - | |||||||||||||||||||||||||
287 | for (i = 0, tt = it->templates; i < it->tcount
| 5266-13933 | ||||||||||||||||||||||||
288 | if (tt->flags & (0x3<<8)
| 5-13928 | ||||||||||||||||||||||||
289 | const ASN1_TEMPLATE *seqtt; | - | ||||||||||||||||||||||||
290 | ASN1_VALUE **pseqval; | - | ||||||||||||||||||||||||
291 | seqtt = asn1_do_adb(pval, tt, 1); | - | ||||||||||||||||||||||||
292 | if (!seqtt
| 0-5 | ||||||||||||||||||||||||
293 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
294 | pseqval = asn1_get_field_ptr(pval, seqtt); | - | ||||||||||||||||||||||||
295 | ASN1_template_free(pseqval, seqtt); | - | ||||||||||||||||||||||||
296 | } executed 5 times by 1 test: end of block Executed by:
| 5 | ||||||||||||||||||||||||
297 | } executed 13933 times by 11 tests: end of block Executed by:
| 13933 | ||||||||||||||||||||||||
298 | - | |||||||||||||||||||||||||
299 | - | |||||||||||||||||||||||||
300 | for (i = 0, tt = it->templates; i < it->tcount
| 4857-13730 | ||||||||||||||||||||||||
301 | const ASN1_TEMPLATE *seqtt; | - | ||||||||||||||||||||||||
302 | ASN1_VALUE **pseqval; | - | ||||||||||||||||||||||||
303 | seqtt = asn1_do_adb(pval, tt, 1); | - | ||||||||||||||||||||||||
304 | if (!seqtt
| 0-13730 | ||||||||||||||||||||||||
305 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
306 | pseqval = asn1_get_field_ptr(pval, seqtt); | - | ||||||||||||||||||||||||
307 | - | |||||||||||||||||||||||||
308 | if (!len
| 409-13321 | ||||||||||||||||||||||||
309 | break; executed 409 times by 6 tests: break; Executed by:
| 409 | ||||||||||||||||||||||||
310 | q = p; | - | ||||||||||||||||||||||||
311 | if (asn1_check_eoc(&p, len)
| 0-13321 | ||||||||||||||||||||||||
312 | if (!seq_eoc
| 0 | ||||||||||||||||||||||||
313 | ERR_put_error(13,(0xfff),(159),__FILE__,368); | - | ||||||||||||||||||||||||
314 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
315 | } | - | ||||||||||||||||||||||||
316 | len -= p - q; | - | ||||||||||||||||||||||||
317 | seq_eoc = 0; | - | ||||||||||||||||||||||||
318 | q = p; | - | ||||||||||||||||||||||||
319 | break; never executed: break; | 0 | ||||||||||||||||||||||||
320 | } | - | ||||||||||||||||||||||||
321 | - | |||||||||||||||||||||||||
322 | - | |||||||||||||||||||||||||
323 | - | |||||||||||||||||||||||||
324 | - | |||||||||||||||||||||||||
325 | - | |||||||||||||||||||||||||
326 | - | |||||||||||||||||||||||||
327 | if (i == (it->tcount - 1)
| 4857-8464 | ||||||||||||||||||||||||
328 | isopt = 0; executed 4857 times by 11 tests: isopt = 0; Executed by:
| 4857 | ||||||||||||||||||||||||
329 | else | - | ||||||||||||||||||||||||
330 | isopt = (char)(seqtt->flags & (0x1)); executed 8464 times by 11 tests: isopt = (char)(seqtt->flags & (0x1)); Executed by:
| 8464 | ||||||||||||||||||||||||
331 | - | |||||||||||||||||||||||||
332 | - | |||||||||||||||||||||||||
333 | - | |||||||||||||||||||||||||
334 | ret = asn1_template_ex_d2i(pseqval, &p, len, | - | ||||||||||||||||||||||||
335 | seqtt, isopt, ctx, depth); | - | ||||||||||||||||||||||||
336 | if (!ret
| 0-13321 | ||||||||||||||||||||||||
337 | errtt = seqtt; | - | ||||||||||||||||||||||||
338 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
339 | } else if (ret == -1
| 741-12580 | ||||||||||||||||||||||||
340 | - | |||||||||||||||||||||||||
341 | - | |||||||||||||||||||||||||
342 | - | |||||||||||||||||||||||||
343 | ASN1_template_free(pseqval, seqtt); | - | ||||||||||||||||||||||||
344 | continue; executed 741 times by 7 tests: continue; Executed by:
| 741 | ||||||||||||||||||||||||
345 | } | - | ||||||||||||||||||||||||
346 | - | |||||||||||||||||||||||||
347 | len -= p - q; | - | ||||||||||||||||||||||||
348 | } executed 12580 times by 11 tests: end of block Executed by:
| 12580 | ||||||||||||||||||||||||
349 | - | |||||||||||||||||||||||||
350 | - | |||||||||||||||||||||||||
351 | if (seq_eoc
| 0-5266 | ||||||||||||||||||||||||
352 | ERR_put_error(13,(0xfff),(137),__FILE__,407); | - | ||||||||||||||||||||||||
353 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
354 | } | - | ||||||||||||||||||||||||
355 | - | |||||||||||||||||||||||||
356 | if (!seq_nolen
| 0-5266 | ||||||||||||||||||||||||
357 | ERR_put_error(13,(0xfff),(148),__FILE__,412); | - | ||||||||||||||||||||||||
358 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
359 | } | - | ||||||||||||||||||||||||
360 | - | |||||||||||||||||||||||||
361 | - | |||||||||||||||||||||||||
362 | - | |||||||||||||||||||||||||
363 | - | |||||||||||||||||||||||||
364 | - | |||||||||||||||||||||||||
365 | for (; i < it->tcount
| 612-5266 | ||||||||||||||||||||||||
366 | const ASN1_TEMPLATE *seqtt; | - | ||||||||||||||||||||||||
367 | seqtt = asn1_do_adb(pval, tt, 1); | - | ||||||||||||||||||||||||
368 | if (!seqtt
| 0-612 | ||||||||||||||||||||||||
369 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
370 | if (seqtt->flags & (0x1)
| 0-612 | ||||||||||||||||||||||||
371 | ASN1_VALUE **pseqval; | - | ||||||||||||||||||||||||
372 | pseqval = asn1_get_field_ptr(pval, seqtt); | - | ||||||||||||||||||||||||
373 | ASN1_template_free(pseqval, seqtt); | - | ||||||||||||||||||||||||
374 | } executed 612 times by 6 tests: else {end of block Executed by:
| 612 | ||||||||||||||||||||||||
375 | errtt = seqtt; | - | ||||||||||||||||||||||||
376 | ERR_put_error(13,(0xfff),(121),__FILE__,431); | - | ||||||||||||||||||||||||
377 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
378 | } | - | ||||||||||||||||||||||||
379 | } | - | ||||||||||||||||||||||||
380 | - | |||||||||||||||||||||||||
381 | if (!asn1_enc_save(pval, *in, p - *in, it)
| 0-5266 | ||||||||||||||||||||||||
382 | ERR_put_error(13,(0xfff),((1|64)),__FILE__,437); | - | ||||||||||||||||||||||||
383 | goto never executed: auxerr;goto auxerr; never executed: goto auxerr; | 0 | ||||||||||||||||||||||||
384 | } | - | ||||||||||||||||||||||||
385 | *in = p; | - | ||||||||||||||||||||||||
386 | if (asn1_cb
| 0-4423 | ||||||||||||||||||||||||
387 | ((void *)0)
| 0-843 | ||||||||||||||||||||||||
388 | )
| 0-843 | ||||||||||||||||||||||||
389 | goto never executed: auxerr;goto auxerr; never executed: goto auxerr; | 0 | ||||||||||||||||||||||||
390 | return executed 5266 times by 11 tests: 1;return 1; Executed by:
executed 5266 times by 11 tests: return 1; Executed by:
| 5266 | ||||||||||||||||||||||||
391 | - | |||||||||||||||||||||||||
392 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||
393 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
394 | } | - | ||||||||||||||||||||||||
395 | - | |||||||||||||||||||||||||
396 | auxerr: code before this statement never executed: auxerr: | 0 | ||||||||||||||||||||||||
397 | ERR_put_error(13,(0xfff),(100),__FILE__,450); | - | ||||||||||||||||||||||||
398 | err: code before this statement never executed: err: | 0 | ||||||||||||||||||||||||
399 | if (combine == 0
| 0-76 | ||||||||||||||||||||||||
400 | ASN1_item_ex_free(pval, it); executed 76 times by 1 test: ASN1_item_ex_free(pval, it); Executed by:
| 76 | ||||||||||||||||||||||||
401 | if (errtt
| 0-76 | ||||||||||||||||||||||||
402 | ERR_asprintf_error_data("Field=%s, Type=%s", errtt->field_name, never executed: ERR_asprintf_error_data("Field=%s, Type=%s", errtt->field_name, it->sname); | 0 | ||||||||||||||||||||||||
403 | it->sname); never executed: ERR_asprintf_error_data("Field=%s, Type=%s", errtt->field_name, it->sname); | 0 | ||||||||||||||||||||||||
404 | else | - | ||||||||||||||||||||||||
405 | ERR_asprintf_error_data("Type=%s", it->sname); executed 76 times by 1 test: ERR_asprintf_error_data("Type=%s", it->sname); Executed by:
| 76 | ||||||||||||||||||||||||
406 | return executed 76 times by 1 test: 0;return 0; Executed by:
executed 76 times by 1 test: return 0; Executed by:
| 76 | ||||||||||||||||||||||||
407 | } | - | ||||||||||||||||||||||||
408 | - | |||||||||||||||||||||||||
409 | int | - | ||||||||||||||||||||||||
410 | ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, | - | ||||||||||||||||||||||||
411 | const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx) | - | ||||||||||||||||||||||||
412 | { | - | ||||||||||||||||||||||||
413 | return executed 2260 times by 12 tests: asn1_item_ex_d2i(pval, in, len, it, tag, aclass, opt, ctx, 0);return asn1_item_ex_d2i(pval, in, len, it, tag, aclass, opt, ctx, 0); Executed by:
executed 2260 times by 12 tests: return asn1_item_ex_d2i(pval, in, len, it, tag, aclass, opt, ctx, 0); Executed by:
| 2260 | ||||||||||||||||||||||||
414 | } | - | ||||||||||||||||||||||||
415 | - | |||||||||||||||||||||||||
416 | - | |||||||||||||||||||||||||
417 | - | |||||||||||||||||||||||||
418 | - | |||||||||||||||||||||||||
419 | - | |||||||||||||||||||||||||
420 | static int | - | ||||||||||||||||||||||||
421 | asn1_template_ex_d2i(ASN1_VALUE **val, const unsigned char **in, long inlen, | - | ||||||||||||||||||||||||
422 | const ASN1_TEMPLATE *tt, char opt, ASN1_TLC *ctx, int depth) | - | ||||||||||||||||||||||||
423 | { | - | ||||||||||||||||||||||||
424 | int flags, aclass; | - | ||||||||||||||||||||||||
425 | int ret; | - | ||||||||||||||||||||||||
426 | long len; | - | ||||||||||||||||||||||||
427 | const unsigned char *p, *q; | - | ||||||||||||||||||||||||
428 | char exp_eoc; | - | ||||||||||||||||||||||||
429 | - | |||||||||||||||||||||||||
430 | if (!val
| 0-15702 | ||||||||||||||||||||||||
431 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
432 | flags = tt->flags; | - | ||||||||||||||||||||||||
433 | aclass = flags & (0x3<<6); | - | ||||||||||||||||||||||||
434 | - | |||||||||||||||||||||||||
435 | p = *in; | - | ||||||||||||||||||||||||
436 | - | |||||||||||||||||||||||||
437 | - | |||||||||||||||||||||||||
438 | if (flags & (0x2 << 3)
| 442-15260 | ||||||||||||||||||||||||
439 | char cst; | - | ||||||||||||||||||||||||
440 | - | |||||||||||||||||||||||||
441 | - | |||||||||||||||||||||||||
442 | - | |||||||||||||||||||||||||
443 | - | |||||||||||||||||||||||||
444 | ret = asn1_check_tlen(&len, | - | ||||||||||||||||||||||||
445 | ((void *)0) | - | ||||||||||||||||||||||||
446 | , | - | ||||||||||||||||||||||||
447 | ((void *)0) | - | ||||||||||||||||||||||||
448 | , &exp_eoc, &cst, | - | ||||||||||||||||||||||||
449 | &p, inlen, tt->tag, aclass, opt, ctx); | - | ||||||||||||||||||||||||
450 | q = p; | - | ||||||||||||||||||||||||
451 | if (!ret
| 0-442 | ||||||||||||||||||||||||
452 | ERR_put_error(13,(0xfff),(58),__FILE__,501); | - | ||||||||||||||||||||||||
453 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
454 | } else if (ret == -1
| 4-438 | ||||||||||||||||||||||||
455 | return executed 4 times by 2 tests: -1;return -1; Executed by:
executed 4 times by 2 tests: return -1; Executed by:
| 4 | ||||||||||||||||||||||||
456 | if (!cst
| 0-438 | ||||||||||||||||||||||||
457 | ERR_put_error(13,(0xfff),(120),__FILE__,506); | - | ||||||||||||||||||||||||
458 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
459 | } | - | ||||||||||||||||||||||||
460 | - | |||||||||||||||||||||||||
461 | ret = asn1_template_noexp_d2i(val, &p, len, tt, 0, ctx, depth); | - | ||||||||||||||||||||||||
462 | if (!ret
| 0-438 | ||||||||||||||||||||||||
463 | ERR_put_error(13,(0xfff),(58),__FILE__,512); | - | ||||||||||||||||||||||||
464 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
465 | } | - | ||||||||||||||||||||||||
466 | - | |||||||||||||||||||||||||
467 | len -= p - q; | - | ||||||||||||||||||||||||
468 | if (exp_eoc
| 0-438 | ||||||||||||||||||||||||
469 | - | |||||||||||||||||||||||||
470 | if (!asn1_check_eoc(&p, len)
| 0 | ||||||||||||||||||||||||
471 | ERR_put_error(13,(0xfff),(137),__FILE__,520); | - | ||||||||||||||||||||||||
472 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
473 | } | - | ||||||||||||||||||||||||
474 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
475 | - | |||||||||||||||||||||||||
476 | - | |||||||||||||||||||||||||
477 | if (len
| 0-438 | ||||||||||||||||||||||||
478 | ERR_put_error(13,(0xfff),(119),__FILE__,527); | - | ||||||||||||||||||||||||
479 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
480 | } | - | ||||||||||||||||||||||||
481 | } executed 438 times by 7 tests: end of block Executed by:
| 438 | ||||||||||||||||||||||||
482 | } else | - | ||||||||||||||||||||||||
483 | return executed 15260 times by 11 tests: asn1_template_noexp_d2i(val, in, inlen, tt, opt, ctx,return asn1_template_noexp_d2i(val, in, inlen, tt, opt, ctx, depth); Executed by:
executed 15260 times by 11 tests: return asn1_template_noexp_d2i(val, in, inlen, tt, opt, ctx, depth); Executed by:
| 15260 | ||||||||||||||||||||||||
484 | depth); executed 15260 times by 11 tests: return asn1_template_noexp_d2i(val, in, inlen, tt, opt, ctx, depth); Executed by:
| 15260 | ||||||||||||||||||||||||
485 | - | |||||||||||||||||||||||||
486 | *in = p; | - | ||||||||||||||||||||||||
487 | return executed 438 times by 7 tests: 1;return 1; Executed by:
executed 438 times by 7 tests: return 1; Executed by:
| 438 | ||||||||||||||||||||||||
488 | - | |||||||||||||||||||||||||
489 | err: | - | ||||||||||||||||||||||||
490 | ASN1_template_free(val, tt); | - | ||||||||||||||||||||||||
491 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
492 | } | - | ||||||||||||||||||||||||
493 | - | |||||||||||||||||||||||||
494 | static int | - | ||||||||||||||||||||||||
495 | asn1_template_noexp_d2i(ASN1_VALUE **val, const unsigned char **in, long len, | - | ||||||||||||||||||||||||
496 | const ASN1_TEMPLATE *tt, char opt, ASN1_TLC *ctx, int depth) | - | ||||||||||||||||||||||||
497 | { | - | ||||||||||||||||||||||||
498 | int flags, aclass; | - | ||||||||||||||||||||||||
499 | int ret; | - | ||||||||||||||||||||||||
500 | const unsigned char *p, *q; | - | ||||||||||||||||||||||||
501 | - | |||||||||||||||||||||||||
502 | if (!val
| 0-15698 | ||||||||||||||||||||||||
503 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
504 | flags = tt->flags; | - | ||||||||||||||||||||||||
505 | aclass = flags & (0x3<<6); | - | ||||||||||||||||||||||||
506 | - | |||||||||||||||||||||||||
507 | p = *in; | - | ||||||||||||||||||||||||
508 | q = p; | - | ||||||||||||||||||||||||
509 | - | |||||||||||||||||||||||||
510 | if (flags & (0x3 << 1)
| 2527-13171 | ||||||||||||||||||||||||
511 | - | |||||||||||||||||||||||||
512 | int sktag, skaclass; | - | ||||||||||||||||||||||||
513 | char sk_eoc; | - | ||||||||||||||||||||||||
514 | - | |||||||||||||||||||||||||
515 | if (flags & (0x1 << 3)
| 6-2521 | ||||||||||||||||||||||||
516 | sktag = tt->tag; | - | ||||||||||||||||||||||||
517 | skaclass = aclass; | - | ||||||||||||||||||||||||
518 | } executed 6 times by 1 test: else {end of block Executed by:
| 6 | ||||||||||||||||||||||||
519 | skaclass = 0x00; | - | ||||||||||||||||||||||||
520 | if (flags & (0x1 << 1)
| 703-1818 | ||||||||||||||||||||||||
521 | sktag = 17; executed 1818 times by 8 tests: sktag = 17; Executed by:
| 1818 | ||||||||||||||||||||||||
522 | else | - | ||||||||||||||||||||||||
523 | sktag = 16; executed 703 times by 8 tests: sktag = 16; Executed by:
| 703 | ||||||||||||||||||||||||
524 | } | - | ||||||||||||||||||||||||
525 | - | |||||||||||||||||||||||||
526 | ret = asn1_check_tlen(&len, | - | ||||||||||||||||||||||||
527 | ((void *)0) | - | ||||||||||||||||||||||||
528 | , | - | ||||||||||||||||||||||||
529 | ((void *)0) | - | ||||||||||||||||||||||||
530 | , &sk_eoc, | - | ||||||||||||||||||||||||
531 | ((void *)0) | - | ||||||||||||||||||||||||
532 | , | - | ||||||||||||||||||||||||
533 | &p, len, sktag, skaclass, opt, ctx); | - | ||||||||||||||||||||||||
534 | if (!ret
| 0-2527 | ||||||||||||||||||||||||
535 | ERR_put_error(13,(0xfff),(58),__FILE__,578); | - | ||||||||||||||||||||||||
536 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
537 | } else if (ret == -1
| 2-2525 | ||||||||||||||||||||||||
538 | return executed 2 times by 1 test: -1;return -1; Executed by:
executed 2 times by 1 test: return -1; Executed by:
| 2 | ||||||||||||||||||||||||
539 | if (!*val
| 5-2520 | ||||||||||||||||||||||||
540 | * executed 2520 times by 8 tests: val = (ASN1_VALUE *)sk_new_null();*val = (ASN1_VALUE *)sk_new_null(); Executed by:
executed 2520 times by 8 tests: *val = (ASN1_VALUE *)sk_new_null(); Executed by:
| 2520 | ||||||||||||||||||||||||
541 | else { | - | ||||||||||||||||||||||||
542 | - | |||||||||||||||||||||||||
543 | struct stack_st_ASN1_VALUE *sktmp = | - | ||||||||||||||||||||||||
544 | (struct stack_st_ASN1_VALUE *)*val; | - | ||||||||||||||||||||||||
545 | ASN1_VALUE *vtmp; | - | ||||||||||||||||||||||||
546 | while (sk_num(((_STACK*) (1 ? (sktmp) : (struct stack_st_ASN1_VALUE*)0))) > 0
| 0-5 | ||||||||||||||||||||||||
547 | vtmp = (ASN1_VALUE *)sk_pop(((_STACK*) (1 ? (sktmp) : (struct stack_st_ASN1_VALUE*)0))); | - | ||||||||||||||||||||||||
548 | ASN1_item_ex_free(&vtmp, | - | ||||||||||||||||||||||||
549 | tt->item); | - | ||||||||||||||||||||||||
550 | } never executed: end of block | 0 | ||||||||||||||||||||||||
551 | } executed 5 times by 1 test: end of block Executed by:
| 5 | ||||||||||||||||||||||||
552 | - | |||||||||||||||||||||||||
553 | if (!*val
| 0-2525 | ||||||||||||||||||||||||
554 | ERR_put_error(13,(0xfff),((1|64)),__FILE__,597); | - | ||||||||||||||||||||||||
555 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
556 | } | - | ||||||||||||||||||||||||
557 | - | |||||||||||||||||||||||||
558 | - | |||||||||||||||||||||||||
559 | while (len > 0
| 2525-4391 | ||||||||||||||||||||||||
560 | ASN1_VALUE *skfield; | - | ||||||||||||||||||||||||
561 | q = p; | - | ||||||||||||||||||||||||
562 | - | |||||||||||||||||||||||||
563 | if (asn1_check_eoc(&p, len)
| 0-4391 | ||||||||||||||||||||||||
564 | if (!sk_eoc
| 0 | ||||||||||||||||||||||||
565 | ERR_put_error(13,(0xfff),(159),__FILE__,608); | - | ||||||||||||||||||||||||
566 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
567 | } | - | ||||||||||||||||||||||||
568 | len -= p - q; | - | ||||||||||||||||||||||||
569 | sk_eoc = 0; | - | ||||||||||||||||||||||||
570 | break; never executed: break; | 0 | ||||||||||||||||||||||||
571 | } | - | ||||||||||||||||||||||||
572 | skfield = | - | ||||||||||||||||||||||||
573 | ((void *)0) | - | ||||||||||||||||||||||||
574 | ; | - | ||||||||||||||||||||||||
575 | if (!asn1_item_ex_d2i(&skfield, &p, len,
| 0-4391 | ||||||||||||||||||||||||
576 | tt->item, -1, 0, 0, ctx, depth)
| 0-4391 | ||||||||||||||||||||||||
577 | ERR_put_error(13,(0xfff),(58),__FILE__,618); | - | ||||||||||||||||||||||||
578 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
579 | } | - | ||||||||||||||||||||||||
580 | len -= p - q; | - | ||||||||||||||||||||||||
581 | if (!sk_push(((_STACK*) (1 ? ((struct stack_st_ASN1_VALUE *)*val) : (struct stack_st_ASN1_VALUE*)0)), ((void*) (1 ? (skfield) : (ASN1_VALUE*)0)))
| 0-4391 | ||||||||||||||||||||||||
582 | ) { | - | ||||||||||||||||||||||||
583 | ERR_put_error(13,(0xfff),((1|64)),__FILE__,624); | - | ||||||||||||||||||||||||
584 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
585 | } | - | ||||||||||||||||||||||||
586 | } executed 4391 times by 8 tests: end of block Executed by:
| 4391 | ||||||||||||||||||||||||
587 | if (sk_eoc
| 0-2525 | ||||||||||||||||||||||||
588 | ERR_put_error(13,(0xfff),(137),__FILE__,629); | - | ||||||||||||||||||||||||
589 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
590 | } | - | ||||||||||||||||||||||||
591 | } executed 2525 times by 8 tests: else if (flags & (0x1 << 3)end of block Executed by:
| 592-12579 | ||||||||||||||||||||||||
592 | - | |||||||||||||||||||||||||
593 | ret = asn1_item_ex_d2i(val, &p, len, | - | ||||||||||||||||||||||||
594 | tt->item, tt->tag, aclass, opt, ctx, depth); | - | ||||||||||||||||||||||||
595 | if (!ret
| 0-592 | ||||||||||||||||||||||||
596 | ERR_put_error(13,(0xfff),(58),__FILE__,637); | - | ||||||||||||||||||||||||
597 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
598 | } else if (ret == -1
| 102-490 | ||||||||||||||||||||||||
599 | return executed 490 times by 8 tests: -1;return -1; Executed by:
executed 490 times by 8 tests: return -1; Executed by:
| 490 | ||||||||||||||||||||||||
600 | } executed 102 times by 5 tests: else {end of block Executed by:
| 102 | ||||||||||||||||||||||||
601 | - | |||||||||||||||||||||||||
602 | ret = asn1_item_ex_d2i(val, &p, len, tt->item, | - | ||||||||||||||||||||||||
603 | -1, tt->flags & (0x1<<10), opt, ctx, depth); | - | ||||||||||||||||||||||||
604 | if (!ret
| 0-12579 | ||||||||||||||||||||||||
605 | ERR_put_error(13,(0xfff),(58),__FILE__,646); | - | ||||||||||||||||||||||||
606 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
607 | } else if (ret == -1
| 303-12276 | ||||||||||||||||||||||||
608 | return executed 303 times by 7 tests: -1;return -1; Executed by:
executed 303 times by 7 tests: return -1; Executed by:
| 303 | ||||||||||||||||||||||||
609 | } executed 12276 times by 11 tests: end of block Executed by:
| 12276 | ||||||||||||||||||||||||
610 | - | |||||||||||||||||||||||||
611 | *in = p; | - | ||||||||||||||||||||||||
612 | return executed 14903 times by 11 tests: 1;return 1; Executed by:
executed 14903 times by 11 tests: return 1; Executed by:
| 14903 | ||||||||||||||||||||||||
613 | - | |||||||||||||||||||||||||
614 | err: | - | ||||||||||||||||||||||||
615 | ASN1_template_free(val, tt); | - | ||||||||||||||||||||||||
616 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
617 | } | - | ||||||||||||||||||||||||
618 | - | |||||||||||||||||||||||||
619 | static int | - | ||||||||||||||||||||||||
620 | asn1_d2i_ex_primitive(ASN1_VALUE **pval, const unsigned char **in, long inlen, | - | ||||||||||||||||||||||||
621 | const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx) | - | ||||||||||||||||||||||||
622 | { | - | ||||||||||||||||||||||||
623 | int ret = 0, utype; | - | ||||||||||||||||||||||||
624 | long plen; | - | ||||||||||||||||||||||||
625 | char cst, inf, free_cont = 0; | - | ||||||||||||||||||||||||
626 | const unsigned char *p; | - | ||||||||||||||||||||||||
627 | BUF_MEM buf; | - | ||||||||||||||||||||||||
628 | const unsigned char *cont = | - | ||||||||||||||||||||||||
629 | ((void *)0) | - | ||||||||||||||||||||||||
630 | ; | - | ||||||||||||||||||||||||
631 | long len; | - | ||||||||||||||||||||||||
632 | - | |||||||||||||||||||||||||
633 | buf.length = 0; | - | ||||||||||||||||||||||||
634 | buf.max = 0; | - | ||||||||||||||||||||||||
635 | buf.data = | - | ||||||||||||||||||||||||
636 | ((void *)0) | - | ||||||||||||||||||||||||
637 | ; | - | ||||||||||||||||||||||||
638 | - | |||||||||||||||||||||||||
639 | if (!pval
| 0-11658 | ||||||||||||||||||||||||
640 | ERR_put_error(13,(0xfff),(125),__FILE__,677); | - | ||||||||||||||||||||||||
641 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
642 | } | - | ||||||||||||||||||||||||
643 | - | |||||||||||||||||||||||||
644 | if (it->itype == 0x5
| 2276-9382 | ||||||||||||||||||||||||
645 | utype = tag; | - | ||||||||||||||||||||||||
646 | tag = -1; | - | ||||||||||||||||||||||||
647 | } executed 2276 times by 8 tests: elseend of block Executed by:
| 2276 | ||||||||||||||||||||||||
648 | utype = it->utype; executed 9382 times by 12 tests: utype = it->utype; Executed by:
| 9382 | ||||||||||||||||||||||||
649 | - | |||||||||||||||||||||||||
650 | if (utype == -4
| 671-10987 | ||||||||||||||||||||||||
651 | - | |||||||||||||||||||||||||
652 | unsigned char oclass; | - | ||||||||||||||||||||||||
653 | if (tag >= 0
| 0-671 | ||||||||||||||||||||||||
654 | ERR_put_error(13,(0xfff),(127),__FILE__,691); | - | ||||||||||||||||||||||||
655 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
656 | } | - | ||||||||||||||||||||||||
657 | if (opt
| 0-671 | ||||||||||||||||||||||||
658 | ERR_put_error(13,(0xfff),(126),__FILE__,695); | - | ||||||||||||||||||||||||
659 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
660 | } | - | ||||||||||||||||||||||||
661 | p = *in; | - | ||||||||||||||||||||||||
662 | ret = asn1_check_tlen( | - | ||||||||||||||||||||||||
663 | ((void *)0) | - | ||||||||||||||||||||||||
664 | , &utype, &oclass, | - | ||||||||||||||||||||||||
665 | ((void *)0) | - | ||||||||||||||||||||||||
666 | , | - | ||||||||||||||||||||||||
667 | ((void *)0) | - | ||||||||||||||||||||||||
668 | , | - | ||||||||||||||||||||||||
669 | &p, inlen, -1, 0, 0, ctx); | - | ||||||||||||||||||||||||
670 | if (!ret
| 0-671 | ||||||||||||||||||||||||
671 | ERR_put_error(13,(0xfff),(58),__FILE__,702); | - | ||||||||||||||||||||||||
672 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
673 | } | - | ||||||||||||||||||||||||
674 | if (oclass != 0x00
| 0-671 | ||||||||||||||||||||||||
675 | utype = -3; never executed: utype = -3; | 0 | ||||||||||||||||||||||||
676 | } executed 671 times by 7 tests: end of block Executed by:
| 671 | ||||||||||||||||||||||||
677 | if (tag == -1
| 566-11092 | ||||||||||||||||||||||||
678 | tag = utype; | - | ||||||||||||||||||||||||
679 | aclass = 0x00; | - | ||||||||||||||||||||||||
680 | } executed 11092 times by 12 tests: end of block Executed by:
| 11092 | ||||||||||||||||||||||||
681 | p = *in; | - | ||||||||||||||||||||||||
682 | - | |||||||||||||||||||||||||
683 | ret = asn1_check_tlen(&plen, | - | ||||||||||||||||||||||||
684 | ((void *)0) | - | ||||||||||||||||||||||||
685 | , | - | ||||||||||||||||||||||||
686 | ((void *)0) | - | ||||||||||||||||||||||||
687 | , &inf, &cst, | - | ||||||||||||||||||||||||
688 | &p, inlen, tag, aclass, opt, ctx); | - | ||||||||||||||||||||||||
689 | if (!ret
| 0-11658 | ||||||||||||||||||||||||
690 | ERR_put_error(13,(0xfff),(58),__FILE__,717); | - | ||||||||||||||||||||||||
691 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
692 | } else if (ret == -1
| 767-10891 | ||||||||||||||||||||||||
693 | return executed 767 times by 8 tests: -1;return -1; Executed by:
executed 767 times by 8 tests: return -1; Executed by:
| 767 | ||||||||||||||||||||||||
694 | ret = 0; | - | ||||||||||||||||||||||||
695 | - | |||||||||||||||||||||||||
696 | if ((
| 0-10888 | ||||||||||||||||||||||||
697 | (
| 0-10888 | ||||||||||||||||||||||||
698 | - | |||||||||||||||||||||||||
699 | - | |||||||||||||||||||||||||
700 | - | |||||||||||||||||||||||||
701 | if (utype == -3
| 0-3 | ||||||||||||||||||||||||
702 | if (ctx
never executed: ctx)->valid = 0;(ctx)->valid = 0; never executed: (ctx)->valid = 0; | 0 | ||||||||||||||||||||||||
703 | } never executed: end of block | 0 | ||||||||||||||||||||||||
704 | - | |||||||||||||||||||||||||
705 | else if (!cst
| 0-3 | ||||||||||||||||||||||||
706 | ERR_put_error(13,(0xfff),(156),__FILE__,733); | - | ||||||||||||||||||||||||
707 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
708 | } | - | ||||||||||||||||||||||||
709 | - | |||||||||||||||||||||||||
710 | cont = *in; | - | ||||||||||||||||||||||||
711 | - | |||||||||||||||||||||||||
712 | if (inf
| 0-3 | ||||||||||||||||||||||||
713 | if (!asn1_find_end(&p, plen, inf)
| 0 | ||||||||||||||||||||||||
714 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
715 | len = p - cont; | - | ||||||||||||||||||||||||
716 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
717 | len = p - cont + plen; | - | ||||||||||||||||||||||||
718 | p += plen; | - | ||||||||||||||||||||||||
719 | buf.data = | - | ||||||||||||||||||||||||
720 | ((void *)0) | - | ||||||||||||||||||||||||
721 | ; | - | ||||||||||||||||||||||||
722 | } executed 3 times by 2 tests: end of block Executed by:
| 3 | ||||||||||||||||||||||||
723 | } else if (cst
| 0-10888 | ||||||||||||||||||||||||
724 | - | |||||||||||||||||||||||||
725 | - | |||||||||||||||||||||||||
726 | - | |||||||||||||||||||||||||
727 | - | |||||||||||||||||||||||||
728 | - | |||||||||||||||||||||||||
729 | - | |||||||||||||||||||||||||
730 | if (!asn1_collect(&buf, &p, plen, inf, -1, 0x00, 0)
| 0 | ||||||||||||||||||||||||
731 | free_cont = 1; | - | ||||||||||||||||||||||||
732 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
733 | } | - | ||||||||||||||||||||||||
734 | len = buf.length; | - | ||||||||||||||||||||||||
735 | - | |||||||||||||||||||||||||
736 | if (!BUF_MEM_grow_clean(&buf, len + 1)
| 0 | ||||||||||||||||||||||||
737 | ERR_put_error(13,(0xfff),((1|64)),__FILE__,762); | - | ||||||||||||||||||||||||
738 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
739 | } | - | ||||||||||||||||||||||||
740 | buf.data[len] = 0; | - | ||||||||||||||||||||||||
741 | cont = (const unsigned char *)buf.data; | - | ||||||||||||||||||||||||
742 | free_cont = 1; | - | ||||||||||||||||||||||||
743 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
744 | cont = p; | - | ||||||||||||||||||||||||
745 | len = plen; | - | ||||||||||||||||||||||||
746 | p += plen; | - | ||||||||||||||||||||||||
747 | } executed 10888 times by 12 tests: end of block Executed by:
| 10888 | ||||||||||||||||||||||||
748 | - | |||||||||||||||||||||||||
749 | - | |||||||||||||||||||||||||
750 | if (!asn1_ex_c2i(pval, cont, len, utype, &free_cont, it)
| 0-10891 | ||||||||||||||||||||||||
751 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
752 | - | |||||||||||||||||||||||||
753 | *in = p; | - | ||||||||||||||||||||||||
754 | ret = 1; | - | ||||||||||||||||||||||||
755 | - | |||||||||||||||||||||||||
756 | err: code before this statement executed 10891 times by 12 tests: err: Executed by:
| 10891 | ||||||||||||||||||||||||
757 | if (free_cont
| 0-10891 | ||||||||||||||||||||||||
758 | free(buf.data); never executed: free(buf.data); | 0 | ||||||||||||||||||||||||
759 | return executed 10891 times by 12 tests: ret;return ret; Executed by:
executed 10891 times by 12 tests: return ret; Executed by:
| 10891 | ||||||||||||||||||||||||
760 | } | - | ||||||||||||||||||||||||
761 | - | |||||||||||||||||||||||||
762 | - | |||||||||||||||||||||||||
763 | - | |||||||||||||||||||||||||
764 | int | - | ||||||||||||||||||||||||
765 | asn1_ex_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype, | - | ||||||||||||||||||||||||
766 | char *free_cont, const ASN1_ITEM *it) | - | ||||||||||||||||||||||||
767 | { | - | ||||||||||||||||||||||||
768 | ASN1_VALUE **opval = | - | ||||||||||||||||||||||||
769 | ((void *)0) | - | ||||||||||||||||||||||||
770 | ; | - | ||||||||||||||||||||||||
771 | ASN1_STRING *stmp; | - | ||||||||||||||||||||||||
772 | ASN1_TYPE *typ = | - | ||||||||||||||||||||||||
773 | ((void *)0) | - | ||||||||||||||||||||||||
774 | ; | - | ||||||||||||||||||||||||
775 | int ret = 0; | - | ||||||||||||||||||||||||
776 | const ASN1_PRIMITIVE_FUNCS *pf; | - | ||||||||||||||||||||||||
777 | ASN1_INTEGER **tint; | - | ||||||||||||||||||||||||
778 | - | |||||||||||||||||||||||||
779 | pf = it->funcs; | - | ||||||||||||||||||||||||
780 | - | |||||||||||||||||||||||||
781 | if (pf
| 0-8713 | ||||||||||||||||||||||||
782 | return executed 2178 times by 7 tests: pf->prim_c2i(pval, cont, len, utype, free_cont, it);return pf->prim_c2i(pval, cont, len, utype, free_cont, it); Executed by:
executed 2178 times by 7 tests: return pf->prim_c2i(pval, cont, len, utype, free_cont, it); Executed by:
| 2178 | ||||||||||||||||||||||||
783 | - | |||||||||||||||||||||||||
784 | if (it->utype == -4
| 671-8042 | ||||||||||||||||||||||||
785 | if (!*pval
| 0-671 | ||||||||||||||||||||||||
786 | typ = ASN1_TYPE_new(); | - | ||||||||||||||||||||||||
787 | if (typ ==
| 0-671 | ||||||||||||||||||||||||
788 | ((void *)0)
| 0-671 | ||||||||||||||||||||||||
789 | ) | - | ||||||||||||||||||||||||
790 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
791 | *pval = (ASN1_VALUE *)typ; | - | ||||||||||||||||||||||||
792 | } executed 671 times by 7 tests: elseend of block Executed by:
| 671 | ||||||||||||||||||||||||
793 | typ = (ASN1_TYPE *)*pval; never executed: typ = (ASN1_TYPE *)*pval; | 0 | ||||||||||||||||||||||||
794 | - | |||||||||||||||||||||||||
795 | if (utype != typ->type
| 0-671 | ||||||||||||||||||||||||
796 | ASN1_TYPE_set(typ, utype, executed 671 times by 7 tests: ASN1_TYPE_set(typ, utype, ((void *)0) ); Executed by:
| 671 | ||||||||||||||||||||||||
797 | ((void *)0) executed 671 times by 7 tests: ASN1_TYPE_set(typ, utype, ((void *)0) ); Executed by:
| 671 | ||||||||||||||||||||||||
798 | ); executed 671 times by 7 tests: ASN1_TYPE_set(typ, utype, ((void *)0) ); Executed by:
| 671 | ||||||||||||||||||||||||
799 | opval = pval; | - | ||||||||||||||||||||||||
800 | pval = &typ->value.asn1_value; | - | ||||||||||||||||||||||||
801 | } executed 671 times by 7 tests: end of block Executed by:
| 671 | ||||||||||||||||||||||||
802 | switch (utype) { | - | ||||||||||||||||||||||||
803 | case executed 3252 times by 8 tests: 6:case 6: Executed by:
executed 3252 times by 8 tests: case 6: Executed by:
| 3252 | ||||||||||||||||||||||||
804 | if (!c2i_ASN1_OBJECT((ASN1_OBJECT **)pval, &cont, len)
| 0-3252 | ||||||||||||||||||||||||
805 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
806 | break; executed 3252 times by 8 tests: break; Executed by:
| 3252 | ||||||||||||||||||||||||
807 | - | |||||||||||||||||||||||||
808 | case executed 661 times by 7 tests: 5:case 5: Executed by:
executed 661 times by 7 tests: case 5: Executed by:
| 661 | ||||||||||||||||||||||||
809 | if (len
| 0-661 | ||||||||||||||||||||||||
810 | ERR_put_error(13,(0xfff),(144),__FILE__,827); | - | ||||||||||||||||||||||||
811 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
812 | } | - | ||||||||||||||||||||||||
813 | *pval = (ASN1_VALUE *)1; | - | ||||||||||||||||||||||||
814 | break; executed 661 times by 7 tests: break; Executed by:
| 661 | ||||||||||||||||||||||||
815 | - | |||||||||||||||||||||||||
816 | case executed 507 times by 7 tests: 1:case 1: Executed by:
executed 507 times by 7 tests: case 1: Executed by:
| 507 | ||||||||||||||||||||||||
817 | if (len != 1
| 0-507 | ||||||||||||||||||||||||
818 | ERR_put_error(13,(0xfff),(106),__FILE__,835); | - | ||||||||||||||||||||||||
819 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
820 | } else { | - | ||||||||||||||||||||||||
821 | ASN1_BOOLEAN *tbool; | - | ||||||||||||||||||||||||
822 | tbool = (ASN1_BOOLEAN *)pval; | - | ||||||||||||||||||||||||
823 | *tbool = *cont; | - | ||||||||||||||||||||||||
824 | } executed 507 times by 7 tests: end of block Executed by:
| 507 | ||||||||||||||||||||||||
825 | break; executed 507 times by 7 tests: break; Executed by:
| 507 | ||||||||||||||||||||||||
826 | - | |||||||||||||||||||||||||
827 | case executed 635 times by 7 tests: 3:case 3: Executed by:
executed 635 times by 7 tests: case 3: Executed by:
| 635 | ||||||||||||||||||||||||
828 | if (!c2i_ASN1_BIT_STRING((ASN1_BIT_STRING **)pval, &cont, len)
| 0-635 | ||||||||||||||||||||||||
829 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
830 | break; executed 635 times by 7 tests: break; Executed by:
| 635 | ||||||||||||||||||||||||
831 | - | |||||||||||||||||||||||||
832 | case executed 449 times by 8 tests: 2:case 2: Executed by:
executed 449 times by 8 tests: case 2: Executed by:
| 449 | ||||||||||||||||||||||||
833 | case never executed: 10:case 10: never executed: case 10: | 0 | ||||||||||||||||||||||||
834 | tint = (ASN1_INTEGER **)pval; | - | ||||||||||||||||||||||||
835 | if (!c2i_ASN1_INTEGER(tint, &cont, len)
| 0-449 | ||||||||||||||||||||||||
836 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
837 | - | |||||||||||||||||||||||||
838 | (*tint)->type = utype | ((*tint)->type & 0x100); | - | ||||||||||||||||||||||||
839 | break; executed 449 times by 8 tests: break; Executed by:
| 449 | ||||||||||||||||||||||||
840 | - | |||||||||||||||||||||||||
841 | case executed 899 times by 9 tests: 4:case 4: Executed by:
executed 899 times by 9 tests: case 4: Executed by:
| 899 | ||||||||||||||||||||||||
842 | case never executed: 18:case 18: never executed: case 18: | 0 | ||||||||||||||||||||||||
843 | case executed 446 times by 6 tests: 19:case 19: Executed by:
executed 446 times by 6 tests: case 19: Executed by:
| 446 | ||||||||||||||||||||||||
844 | case never executed: 20:case 20: never executed: case 20: | 0 | ||||||||||||||||||||||||
845 | case never executed: 21:case 21: never executed: case 21: | 0 | ||||||||||||||||||||||||
846 | case executed 23 times by 2 tests: 22:case 22: Executed by:
executed 23 times by 2 tests: case 22: Executed by:
| 23 | ||||||||||||||||||||||||
847 | case executed 444 times by 8 tests: 23:case 23: Executed by:
executed 444 times by 8 tests: case 23: Executed by:
| 444 | ||||||||||||||||||||||||
848 | case executed 2 times by 1 test: 24:case 24: Executed by:
executed 2 times by 1 test: case 24: Executed by:
| 2 | ||||||||||||||||||||||||
849 | case never executed: 25:case 25: never executed: case 25: | 0 | ||||||||||||||||||||||||
850 | case never executed: 26:case 26: never executed: case 26: | 0 | ||||||||||||||||||||||||
851 | case never executed: 27:case 27: never executed: case 27: | 0 | ||||||||||||||||||||||||
852 | case never executed: 28:case 28: never executed: case 28: | 0 | ||||||||||||||||||||||||
853 | case never executed: 30:case 30: never executed: case 30: | 0 | ||||||||||||||||||||||||
854 | case executed 1392 times by 8 tests: 12:case 12: Executed by:
executed 1392 times by 8 tests: case 12: Executed by:
| 1392 | ||||||||||||||||||||||||
855 | case never executed: -3:case -3: never executed: case -3: | 0 | ||||||||||||||||||||||||
856 | case never executed: 17:case 17: never executed: case 17: | 0 | ||||||||||||||||||||||||
857 | case executed 3 times by 2 tests: 16:case 16: Executed by:
executed 3 times by 2 tests: case 16: Executed by:
| 3 | ||||||||||||||||||||||||
858 | default never executed: :default: never executed: default: | 0 | ||||||||||||||||||||||||
859 | if (utype == 30
| 0-3209 | ||||||||||||||||||||||||
860 | ERR_put_error(13,(0xfff),(214),__FILE__,877); | - | ||||||||||||||||||||||||
861 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
862 | } | - | ||||||||||||||||||||||||
863 | if (utype == 28
| 0-3209 | ||||||||||||||||||||||||
864 | ERR_put_error(13,(0xfff),(215),__FILE__,881); | - | ||||||||||||||||||||||||
865 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
866 | } | - | ||||||||||||||||||||||||
867 | - | |||||||||||||||||||||||||
868 | if (!*pval
| 189-3020 | ||||||||||||||||||||||||
869 | stmp = ASN1_STRING_type_new(utype); | - | ||||||||||||||||||||||||
870 | if (!stmp
| 0-189 | ||||||||||||||||||||||||
871 | ERR_put_error(13,(0xfff),((1|64)),__FILE__,888); | - | ||||||||||||||||||||||||
872 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
873 | } | - | ||||||||||||||||||||||||
874 | *pval = (ASN1_VALUE *)stmp; | - | ||||||||||||||||||||||||
875 | } executed 189 times by 6 tests: else {end of block Executed by:
| 189 | ||||||||||||||||||||||||
876 | stmp = (ASN1_STRING *)*pval; | - | ||||||||||||||||||||||||
877 | stmp->type = utype; | - | ||||||||||||||||||||||||
878 | } executed 3020 times by 10 tests: end of block Executed by:
| 3020 | ||||||||||||||||||||||||
879 | - | |||||||||||||||||||||||||
880 | if (*
| 0-3209 | ||||||||||||||||||||||||
881 | free(stmp->data); | - | ||||||||||||||||||||||||
882 | stmp->data = (unsigned char *)cont; | - | ||||||||||||||||||||||||
883 | stmp->length = len; | - | ||||||||||||||||||||||||
884 | *free_cont = 0; | - | ||||||||||||||||||||||||
885 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
886 | if (!ASN1_STRING_set(stmp, cont, len)
| 0-3209 | ||||||||||||||||||||||||
887 | ERR_put_error(13,(0xfff),((1|64)),__FILE__,904); | - | ||||||||||||||||||||||||
888 | ASN1_STRING_free(stmp); | - | ||||||||||||||||||||||||
889 | *pval = | - | ||||||||||||||||||||||||
890 | ((void *)0) | - | ||||||||||||||||||||||||
891 | ; | - | ||||||||||||||||||||||||
892 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||||||||||||||
893 | } | - | ||||||||||||||||||||||||
894 | } executed 3209 times by 10 tests: end of block Executed by:
| 3209 | ||||||||||||||||||||||||
895 | break; executed 3209 times by 10 tests: break; Executed by:
| 3209 | ||||||||||||||||||||||||
896 | } | - | ||||||||||||||||||||||||
897 | - | |||||||||||||||||||||||||
898 | if (typ
| 10-8042 | ||||||||||||||||||||||||
899 | typ->value.ptr = executed 661 times by 7 tests: typ->value.ptr = ((void *)0) ; Executed by:
| 661 | ||||||||||||||||||||||||
900 | ((void *)0) executed 661 times by 7 tests: typ->value.ptr = ((void *)0) ; Executed by:
| 661 | ||||||||||||||||||||||||
901 | ; executed 661 times by 7 tests: typ->value.ptr = ((void *)0) ; Executed by:
| 661 | ||||||||||||||||||||||||
902 | - | |||||||||||||||||||||||||
903 | ret = 1; | - | ||||||||||||||||||||||||
904 | - | |||||||||||||||||||||||||
905 | err: code before this statement executed 8713 times by 10 tests: err: Executed by:
| 8713 | ||||||||||||||||||||||||
906 | if (!ret
| 0-8713 | ||||||||||||||||||||||||
907 | ASN1_TYPE_free(typ); | - | ||||||||||||||||||||||||
908 | if (opval
| 0 | ||||||||||||||||||||||||
909 | * never executed: opval = *opval = ((void *)0) ; never executed: *opval = ((void *)0) ; | 0 | ||||||||||||||||||||||||
910 | ((void *)0) never executed: *opval = ((void *)0) ; | 0 | ||||||||||||||||||||||||
911 | ; never executed: *opval = ((void *)0) ; | 0 | ||||||||||||||||||||||||
912 | } never executed: end of block | 0 | ||||||||||||||||||||||||
913 | return executed 8713 times by 10 tests: ret;return ret; Executed by:
executed 8713 times by 10 tests: return ret; Executed by:
| 8713 | ||||||||||||||||||||||||
914 | } | - | ||||||||||||||||||||||||
915 | static int | - | ||||||||||||||||||||||||
916 | asn1_find_end(const unsigned char **in, long len, char inf) | - | ||||||||||||||||||||||||
917 | { | - | ||||||||||||||||||||||||
918 | int expected_eoc; | - | ||||||||||||||||||||||||
919 | long plen; | - | ||||||||||||||||||||||||
920 | const unsigned char *p = *in, *q; | - | ||||||||||||||||||||||||
921 | - | |||||||||||||||||||||||||
922 | - | |||||||||||||||||||||||||
923 | if (inf == 0
| 0 | ||||||||||||||||||||||||
924 | *in += len; | - | ||||||||||||||||||||||||
925 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||
926 | } | - | ||||||||||||||||||||||||
927 | expected_eoc = 1; | - | ||||||||||||||||||||||||
928 | - | |||||||||||||||||||||||||
929 | - | |||||||||||||||||||||||||
930 | - | |||||||||||||||||||||||||
931 | - | |||||||||||||||||||||||||
932 | - | |||||||||||||||||||||||||
933 | while (len > 0
| 0 | ||||||||||||||||||||||||
934 | if (asn1_check_eoc(&p, len)
| 0 | ||||||||||||||||||||||||
935 | expected_eoc--; | - | ||||||||||||||||||||||||
936 | if (expected_eoc == 0
| 0 | ||||||||||||||||||||||||
937 | break; never executed: break; | 0 | ||||||||||||||||||||||||
938 | len -= 2; | - | ||||||||||||||||||||||||
939 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
940 | } | - | ||||||||||||||||||||||||
941 | q = p; | - | ||||||||||||||||||||||||
942 | - | |||||||||||||||||||||||||
943 | if (!asn1_check_tlen(&plen,
| 0 | ||||||||||||||||||||||||
944 | ((void *)0)
| 0 | ||||||||||||||||||||||||
945 | ,
| 0 | ||||||||||||||||||||||||
946 | ((void *)0)
| 0 | ||||||||||||||||||||||||
947 | , &inf,
| 0 | ||||||||||||||||||||||||
948 | ((void *)0)
| 0 | ||||||||||||||||||||||||
949 | , &p, len,
| 0 | ||||||||||||||||||||||||
950 | -1, 0, 0,
| 0 | ||||||||||||||||||||||||
951 | ((void *)0)
| 0 | ||||||||||||||||||||||||
952 | )
| 0 | ||||||||||||||||||||||||
953 | ERR_put_error(13,(0xfff),(58),__FILE__,964); | - | ||||||||||||||||||||||||
954 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
955 | } | - | ||||||||||||||||||||||||
956 | if (inf
| 0 | ||||||||||||||||||||||||
957 | expected_eoc++; never executed: expected_eoc++; | 0 | ||||||||||||||||||||||||
958 | else | - | ||||||||||||||||||||||||
959 | p += plen; never executed: p += plen; | 0 | ||||||||||||||||||||||||
960 | len -= p - q; | - | ||||||||||||||||||||||||
961 | } never executed: end of block | 0 | ||||||||||||||||||||||||
962 | if (expected_eoc
| 0 | ||||||||||||||||||||||||
963 | ERR_put_error(13,(0xfff),(137),__FILE__,974); | - | ||||||||||||||||||||||||
964 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
965 | } | - | ||||||||||||||||||||||||
966 | *in = p; | - | ||||||||||||||||||||||||
967 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||
968 | } | - | ||||||||||||||||||||||||
969 | static int | - | ||||||||||||||||||||||||
970 | asn1_collect(BUF_MEM *buf, const unsigned char **in, long len, char inf, | - | ||||||||||||||||||||||||
971 | int tag, int aclass, int depth) | - | ||||||||||||||||||||||||
972 | { | - | ||||||||||||||||||||||||
973 | const unsigned char *p, *q; | - | ||||||||||||||||||||||||
974 | long plen; | - | ||||||||||||||||||||||||
975 | char cst, ininf; | - | ||||||||||||||||||||||||
976 | - | |||||||||||||||||||||||||
977 | p = *in; | - | ||||||||||||||||||||||||
978 | inf &= 1; | - | ||||||||||||||||||||||||
979 | - | |||||||||||||||||||||||||
980 | - | |||||||||||||||||||||||||
981 | if (!buf
| 0 | ||||||||||||||||||||||||
982 | *in += len; | - | ||||||||||||||||||||||||
983 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||
984 | } | - | ||||||||||||||||||||||||
985 | while (len > 0
| 0 | ||||||||||||||||||||||||
986 | q = p; | - | ||||||||||||||||||||||||
987 | - | |||||||||||||||||||||||||
988 | if (asn1_check_eoc(&p, len)
| 0 | ||||||||||||||||||||||||
989 | - | |||||||||||||||||||||||||
990 | - | |||||||||||||||||||||||||
991 | if (!inf
| 0 | ||||||||||||||||||||||||
992 | ERR_put_error(13,(0xfff),(159),__FILE__,1018); | - | ||||||||||||||||||||||||
993 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
994 | } | - | ||||||||||||||||||||||||
995 | inf = 0; | - | ||||||||||||||||||||||||
996 | break; never executed: break; | 0 | ||||||||||||||||||||||||
997 | } | - | ||||||||||||||||||||||||
998 | - | |||||||||||||||||||||||||
999 | if (!asn1_check_tlen(&plen,
| 0 | ||||||||||||||||||||||||
1000 | ((void *)0)
| 0 | ||||||||||||||||||||||||
1001 | ,
| 0 | ||||||||||||||||||||||||
1002 | ((void *)0)
| 0 | ||||||||||||||||||||||||
1003 | , &ininf, &cst, &p,
| 0 | ||||||||||||||||||||||||
1004 | len, tag, aclass, 0,
| 0 | ||||||||||||||||||||||||
1005 | ((void *)0)
| 0 | ||||||||||||||||||||||||
1006 | )
| 0 | ||||||||||||||||||||||||
1007 | ERR_put_error(13,(0xfff),(58),__FILE__,1027); | - | ||||||||||||||||||||||||
1008 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
1009 | } | - | ||||||||||||||||||||||||
1010 | - | |||||||||||||||||||||||||
1011 | - | |||||||||||||||||||||||||
1012 | if (cst
| 0 | ||||||||||||||||||||||||
1013 | if (depth >= 5
| 0 | ||||||||||||||||||||||||
1014 | ERR_put_error(13,(0xfff),(197),__FILE__,1034); | - | ||||||||||||||||||||||||
1015 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
1016 | } | - | ||||||||||||||||||||||||
1017 | if (!asn1_collect(buf, &p, plen, ininf, tag, aclass,
| 0 | ||||||||||||||||||||||||
1018 | depth + 1)
| 0 | ||||||||||||||||||||||||
1019 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
1020 | } never executed: else if (plenend of block
| 0 | ||||||||||||||||||||||||
1021 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
1022 | len -= p - q; | - | ||||||||||||||||||||||||
1023 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1024 | if (inf
| 0 | ||||||||||||||||||||||||
1025 | ERR_put_error(13,(0xfff),(137),__FILE__,1045); | - | ||||||||||||||||||||||||
1026 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
1027 | } | - | ||||||||||||||||||||||||
1028 | *in = p; | - | ||||||||||||||||||||||||
1029 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||
1030 | } | - | ||||||||||||||||||||||||
1031 | - | |||||||||||||||||||||||||
1032 | static int | - | ||||||||||||||||||||||||
1033 | collect_data(BUF_MEM *buf, const unsigned char **p, long plen) | - | ||||||||||||||||||||||||
1034 | { | - | ||||||||||||||||||||||||
1035 | int len; | - | ||||||||||||||||||||||||
1036 | if (buf
| 0 | ||||||||||||||||||||||||
1037 | len = buf->length; | - | ||||||||||||||||||||||||
1038 | if (!BUF_MEM_grow_clean(buf, len + plen)
| 0 | ||||||||||||||||||||||||
1039 | ERR_put_error(13,(0xfff),((1|64)),__FILE__,1059); | - | ||||||||||||||||||||||||
1040 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
1041 | } | - | ||||||||||||||||||||||||
1042 | memcpy(buf->data + len, *p, plen); | - | ||||||||||||||||||||||||
1043 | } never executed: end of block | 0 | ||||||||||||||||||||||||
1044 | *p += plen; | - | ||||||||||||||||||||||||
1045 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||
1046 | } | - | ||||||||||||||||||||||||
1047 | - | |||||||||||||||||||||||||
1048 | - | |||||||||||||||||||||||||
1049 | - | |||||||||||||||||||||||||
1050 | static int | - | ||||||||||||||||||||||||
1051 | asn1_check_eoc(const unsigned char **in, long len) | - | ||||||||||||||||||||||||
1052 | { | - | ||||||||||||||||||||||||
1053 | const unsigned char *p; | - | ||||||||||||||||||||||||
1054 | - | |||||||||||||||||||||||||
1055 | if (len < 2
| 0-17712 | ||||||||||||||||||||||||
1056 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
1057 | p = *in; | - | ||||||||||||||||||||||||
1058 | if (!p[0]
| 0-17712 | ||||||||||||||||||||||||
1059 | *in += 2; | - | ||||||||||||||||||||||||
1060 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||||||||||||||
1061 | } | - | ||||||||||||||||||||||||
1062 | return executed 17712 times by 11 tests: 0;return 0; Executed by:
executed 17712 times by 11 tests: return 0; Executed by:
| 17712 | ||||||||||||||||||||||||
1063 | } | - | ||||||||||||||||||||||||
1064 | static int | - | ||||||||||||||||||||||||
1065 | asn1_check_tlen(long *olen, int *otag, unsigned char *oclass, char *inf, | - | ||||||||||||||||||||||||
1066 | char *cst, const unsigned char **in, long len, int exptag, int expclass, | - | ||||||||||||||||||||||||
1067 | char opt, ASN1_TLC *ctx) | - | ||||||||||||||||||||||||
1068 | { | - | ||||||||||||||||||||||||
1069 | int i; | - | ||||||||||||||||||||||||
1070 | int ptag, pclass; | - | ||||||||||||||||||||||||
1071 | long plen; | - | ||||||||||||||||||||||||
1072 | const unsigned char *p, *q; | - | ||||||||||||||||||||||||
1073 | - | |||||||||||||||||||||||||
1074 | p = *in; | - | ||||||||||||||||||||||||
1075 | q = p; | - | ||||||||||||||||||||||||
1076 | - | |||||||||||||||||||||||||
1077 | if (ctx
| 0-22942 | ||||||||||||||||||||||||
1078 | i = ctx->ret; | - | ||||||||||||||||||||||||
1079 | plen = ctx->plen; | - | ||||||||||||||||||||||||
1080 | pclass = ctx->pclass; | - | ||||||||||||||||||||||||
1081 | ptag = ctx->ptag; | - | ||||||||||||||||||||||||
1082 | p += ctx->hdrlen; | - | ||||||||||||||||||||||||
1083 | } executed 3746 times by 8 tests: else {end of block Executed by:
| 3746 | ||||||||||||||||||||||||
1084 | i = ASN1_get_object(&p, &plen, &ptag, &pclass, len); | - | ||||||||||||||||||||||||
1085 | if (ctx
| 0-19196 | ||||||||||||||||||||||||
1086 | ctx->ret = i; | - | ||||||||||||||||||||||||
1087 | ctx->plen = plen; | - | ||||||||||||||||||||||||
1088 | ctx->pclass = pclass; | - | ||||||||||||||||||||||||
1089 | ctx->ptag = ptag; | - | ||||||||||||||||||||||||
1090 | ctx->hdrlen = p - q; | - | ||||||||||||||||||||||||
1091 | ctx->valid = 1; | - | ||||||||||||||||||||||||
1092 | - | |||||||||||||||||||||||||
1093 | - | |||||||||||||||||||||||||
1094 | - | |||||||||||||||||||||||||
1095 | if (!(i & 0x81)
| 0-19120 | ||||||||||||||||||||||||
1096 | ERR_put_error(13,(0xfff),(155),__FILE__,1124); | - | ||||||||||||||||||||||||
1097 | if (ctx
never executed: ctx)->valid = 0;(ctx)->valid = 0; never executed: (ctx)->valid = 0; | 0 | ||||||||||||||||||||||||
1098 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
1099 | } | - | ||||||||||||||||||||||||
1100 | } executed 19196 times by 12 tests: end of block Executed by:
| 19196 | ||||||||||||||||||||||||
1101 | } executed 19196 times by 12 tests: end of block Executed by:
| 19196 | ||||||||||||||||||||||||
1102 | - | |||||||||||||||||||||||||
1103 | if (i & 0x80
| 76-22866 | ||||||||||||||||||||||||
1104 | ERR_put_error(13,(0xfff),(102),__FILE__,1132); | - | ||||||||||||||||||||||||
1105 | if (ctx
executed 76 times by 1 test: ctx)->valid = 0;(ctx)->valid = 0; Executed by:
executed 76 times by 1 test: (ctx)->valid = 0; Executed by:
| 0-76 | ||||||||||||||||||||||||
1106 | return executed 76 times by 1 test: 0;return 0; Executed by:
executed 76 times by 1 test: return 0; Executed by:
| 76 | ||||||||||||||||||||||||
1107 | } | - | ||||||||||||||||||||||||
1108 | if (exptag >= 0
| 2947-19919 | ||||||||||||||||||||||||
1109 | if ((
| 0-19120 | ||||||||||||||||||||||||
1110 | - | |||||||||||||||||||||||||
1111 | - | |||||||||||||||||||||||||
1112 | - | |||||||||||||||||||||||||
1113 | if (opt
| 0-799 | ||||||||||||||||||||||||
1114 | return executed 799 times by 8 tests: -1;return -1; Executed by:
executed 799 times by 8 tests: return -1; Executed by:
| 799 | ||||||||||||||||||||||||
1115 | if (ctx
never executed: ctx)->valid = 0;(ctx)->valid = 0; never executed: (ctx)->valid = 0; | 0 | ||||||||||||||||||||||||
1116 | ERR_put_error(13,(0xfff),(168),__FILE__,1144); | - | ||||||||||||||||||||||||
1117 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||||||||
1118 | } | - | ||||||||||||||||||||||||
1119 | - | |||||||||||||||||||||||||
1120 | - | |||||||||||||||||||||||||
1121 | if (ctx
executed 19120 times by 12 tests: ctx)->valid = 0;(ctx)->valid = 0; Executed by:
executed 19120 times by 12 tests: (ctx)->valid = 0; Executed by:
| 0-19120 | ||||||||||||||||||||||||
1122 | } executed 19120 times by 12 tests: end of block Executed by:
| 19120 | ||||||||||||||||||||||||
1123 | - | |||||||||||||||||||||||||
1124 | if (i & 1
| 0-22067 | ||||||||||||||||||||||||
1125 | plen = len - (p - q); never executed: plen = len - (p - q); | 0 | ||||||||||||||||||||||||
1126 | if (inf
| 2947-19120 | ||||||||||||||||||||||||
1127 | * executed 19120 times by 12 tests: inf = i & 1;*inf = i & 1; Executed by:
executed 19120 times by 12 tests: *inf = i & 1; Executed by:
| 19120 | ||||||||||||||||||||||||
1128 | if (cst
| 5472-16595 | ||||||||||||||||||||||||
1129 | * executed 16595 times by 12 tests: cst = i & 0x20;*cst = i & 0x20; Executed by:
executed 16595 times by 12 tests: *cst = i & 0x20; Executed by:
| 16595 | ||||||||||||||||||||||||
1130 | if (olen
| 2947-19120 | ||||||||||||||||||||||||
1131 | * executed 19120 times by 12 tests: olen = plen;*olen = plen; Executed by:
executed 19120 times by 12 tests: *olen = plen; Executed by:
| 19120 | ||||||||||||||||||||||||
1132 | if (oclass
| 2947-19120 | ||||||||||||||||||||||||
1133 | * executed 2947 times by 8 tests: oclass = pclass;*oclass = pclass; Executed by:
executed 2947 times by 8 tests: *oclass = pclass; Executed by:
| 2947 | ||||||||||||||||||||||||
1134 | if (otag
| 2947-19120 | ||||||||||||||||||||||||
1135 | * executed 2947 times by 8 tests: otag = ptag;*otag = ptag; Executed by:
executed 2947 times by 8 tests: *otag = ptag; Executed by:
| 2947 | ||||||||||||||||||||||||
1136 | - | |||||||||||||||||||||||||
1137 | *in = p; | - | ||||||||||||||||||||||||
1138 | return executed 22067 times by 12 tests: 1;return 1; Executed by:
executed 22067 times by 12 tests: return 1; Executed by:
| 22067 | ||||||||||||||||||||||||
1139 | } | - | ||||||||||||||||||||||||
Switch to Source code | Preprocessed file |