Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/x509v3/v3_lib.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | static struct stack_st_X509V3_EXT_METHOD *ext_list = | - | ||||||||||||
4 | ((void *)0) | - | ||||||||||||
5 | ; | - | ||||||||||||
6 | - | |||||||||||||
7 | static int ext_cmp(const X509V3_EXT_METHOD *const *a, | - | ||||||||||||
8 | const X509V3_EXT_METHOD *const *b); | - | ||||||||||||
9 | static void ext_list_free(X509V3_EXT_METHOD *ext); | - | ||||||||||||
10 | - | |||||||||||||
11 | int X509V3_EXT_add(X509V3_EXT_METHOD *ext) | - | ||||||||||||
12 | { | - | ||||||||||||
13 | if (ext_list ==
| 0 | ||||||||||||
14 | ((void *)0)
| 0 | ||||||||||||
15 | - | |||||||||||||
16 | && (
| 0 | ||||||||||||
17 | ((void *)0)
| 0 | ||||||||||||
18 | ) { | - | ||||||||||||
19 | ERR_put_error(34,(104),((1|64)),__FILE__,29); | - | ||||||||||||
20 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
21 | } | - | ||||||||||||
22 | if (!sk_X509V3_EXT_METHOD_push(ext_list, ext)
| 0 | ||||||||||||
23 | ERR_put_error(34,(104),((1|64)),__FILE__,33); | - | ||||||||||||
24 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
25 | } | - | ||||||||||||
26 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||
27 | } | - | ||||||||||||
28 | - | |||||||||||||
29 | static int ext_cmp(const X509V3_EXT_METHOD *const *a, | - | ||||||||||||
30 | const X509V3_EXT_METHOD *const *b) | - | ||||||||||||
31 | { | - | ||||||||||||
32 | return executed 920369 times by 1 test: ((*a)->ext_nid - (*b)->ext_nid);return ((*a)->ext_nid - (*b)->ext_nid); Executed by:
executed 920369 times by 1 test: return ((*a)->ext_nid - (*b)->ext_nid); Executed by:
| 920369 | ||||||||||||
33 | } | - | ||||||||||||
34 | - | |||||||||||||
35 | static int ext_cmp_BSEARCH_CMP_FN(const void *, const void *); static int ext_cmp(const X509V3_EXT_METHOD * const *, const X509V3_EXT_METHOD * const *); static const X509V3_EXT_METHOD * * OBJ_bsearch_ext(const X509V3_EXT_METHOD * *key, const X509V3_EXT_METHOD * const *base, int num) | - | ||||||||||||
36 | ; | - | ||||||||||||
37 | static int ext_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) { const X509V3_EXT_METHOD * const *a = a_; const X509V3_EXT_METHOD * const *b = b_; return executed 920369 times by 1 test: ext_cmp(a,b);return ext_cmp(a,b); Executed by:
executed 920369 times by 1 test: } static const X509V3_EXT_METHOD * *OBJ_bsearch_ext(const X509V3_EXT_METHOD * *key, const X509V3_EXT_METHOD * const *base, int num) { returnreturn ext_cmp(a,b); Executed by:
executed 190374 times by 1 test: (const X509V3_EXT_METHOD * *)OBJ_bsearch_(key, base, num, sizeof(const X509V3_EXT_METHOD *), ext_cmp_BSEARCH_CMP_FN);return (const X509V3_EXT_METHOD * *)OBJ_bsearch_(key, base, num, sizeof(const X509V3_EXT_METHOD *), ext_cmp_BSEARCH_CMP_FN); Executed by:
executed 190374 times by 1 test: } extern void dummy_prototype(void)return (const X509V3_EXT_METHOD * *)OBJ_bsearch_(key, base, num, sizeof(const X509V3_EXT_METHOD *), ext_cmp_BSEARCH_CMP_FN); Executed by:
| 190374-920369 | ||||||||||||
38 | ; | - | ||||||||||||
39 | - | |||||||||||||
40 | - | |||||||||||||
41 | const X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid) | - | ||||||||||||
42 | { | - | ||||||||||||
43 | X509V3_EXT_METHOD tmp; | - | ||||||||||||
44 | const X509V3_EXT_METHOD *t = &tmp, *const *ret; | - | ||||||||||||
45 | int idx; | - | ||||||||||||
46 | - | |||||||||||||
47 | if (nid < 0
| 0-190374 | ||||||||||||
48 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||
49 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||
50 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||
51 | tmp.ext_nid = nid; | - | ||||||||||||
52 | ret = OBJ_bsearch_ext(&t, standard_exts, (sizeof(standard_exts)/sizeof((standard_exts)[0]))); | - | ||||||||||||
53 | if (ret
| 4404-185970 | ||||||||||||
54 | return executed 185970 times by 1 test: *ret;return *ret; Executed by:
executed 185970 times by 1 test: return *ret; Executed by:
| 185970 | ||||||||||||
55 | if (!ext_list
| 0-4404 | ||||||||||||
56 | return executed 4404 times by 1 test: return ((void *)0) ; Executed by:
executed 4404 times by 1 test: return ((void *)0) ; Executed by:
| 4404 | ||||||||||||
57 | ((void *)0) executed 4404 times by 1 test: return ((void *)0) ; Executed by:
| 4404 | ||||||||||||
58 | ; executed 4404 times by 1 test: return ((void *)0) ; Executed by:
| 4404 | ||||||||||||
59 | idx = sk_X509V3_EXT_METHOD_find(ext_list, &tmp); | - | ||||||||||||
60 | return never executed: sk_X509V3_EXT_METHOD_value(ext_list, idx);return sk_X509V3_EXT_METHOD_value(ext_list, idx); never executed: return sk_X509V3_EXT_METHOD_value(ext_list, idx); | 0 | ||||||||||||
61 | } | - | ||||||||||||
62 | - | |||||||||||||
63 | const X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext) | - | ||||||||||||
64 | { | - | ||||||||||||
65 | int nid; | - | ||||||||||||
66 | if ((
| 9295-190153 | ||||||||||||
67 | return executed 9295 times by 1 test: return ((void *)0) ; Executed by:
executed 9295 times by 1 test: return ((void *)0) ; Executed by:
| 9295 | ||||||||||||
68 | ((void *)0) executed 9295 times by 1 test: return ((void *)0) ; Executed by:
| 9295 | ||||||||||||
69 | ; executed 9295 times by 1 test: return ((void *)0) ; Executed by:
| 9295 | ||||||||||||
70 | return executed 190153 times by 1 test: X509V3_EXT_get_nid(nid);return X509V3_EXT_get_nid(nid); Executed by:
executed 190153 times by 1 test: return X509V3_EXT_get_nid(nid); Executed by:
| 190153 | ||||||||||||
71 | } | - | ||||||||||||
72 | - | |||||||||||||
73 | int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist) | - | ||||||||||||
74 | { | - | ||||||||||||
75 | for (; extlist->ext_nid != -1
| 0 | ||||||||||||
76 | if (!X509V3_EXT_add(extlist)
| 0 | ||||||||||||
77 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
78 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||
79 | } | - | ||||||||||||
80 | - | |||||||||||||
81 | int X509V3_EXT_add_alias(int nid_to, int nid_from) | - | ||||||||||||
82 | { | - | ||||||||||||
83 | const X509V3_EXT_METHOD *ext; | - | ||||||||||||
84 | X509V3_EXT_METHOD *tmpext; | - | ||||||||||||
85 | - | |||||||||||||
86 | if ((
| 0 | ||||||||||||
87 | ((void *)0)
| 0 | ||||||||||||
88 | ) { | - | ||||||||||||
89 | ERR_put_error(34,(106),(102),__FILE__,92); | - | ||||||||||||
90 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
91 | } | - | ||||||||||||
92 | if ((
| 0 | ||||||||||||
93 | ((void *)0)
| 0 | ||||||||||||
94 | ) { | - | ||||||||||||
95 | ERR_put_error(34,(106),((1|64)),__FILE__,96); | - | ||||||||||||
96 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
97 | } | - | ||||||||||||
98 | *tmpext = *ext; | - | ||||||||||||
99 | tmpext->ext_nid = nid_to; | - | ||||||||||||
100 | tmpext->ext_flags |= 0x1; | - | ||||||||||||
101 | return never executed: X509V3_EXT_add(tmpext);return X509V3_EXT_add(tmpext); never executed: return X509V3_EXT_add(tmpext); | 0 | ||||||||||||
102 | } | - | ||||||||||||
103 | - | |||||||||||||
104 | void X509V3_EXT_cleanup(void) | - | ||||||||||||
105 | { | - | ||||||||||||
106 | sk_X509V3_EXT_METHOD_pop_free(ext_list, ext_list_free); | - | ||||||||||||
107 | ext_list = | - | ||||||||||||
108 | ((void *)0) | - | ||||||||||||
109 | ; | - | ||||||||||||
110 | } never executed: end of block | 0 | ||||||||||||
111 | - | |||||||||||||
112 | static void ext_list_free(X509V3_EXT_METHOD *ext) | - | ||||||||||||
113 | { | - | ||||||||||||
114 | if (ext->ext_flags & 0x1
| 0 | ||||||||||||
115 | CRYPTO_free(ext, __FILE__, 114); never executed: CRYPTO_free(ext, __FILE__, 114); | 0 | ||||||||||||
116 | } never executed: end of block | 0 | ||||||||||||
117 | - | |||||||||||||
118 | - | |||||||||||||
119 | - | |||||||||||||
120 | - | |||||||||||||
121 | - | |||||||||||||
122 | - | |||||||||||||
123 | int X509V3_add_standard_extensions(void) | - | ||||||||||||
124 | { | - | ||||||||||||
125 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||
126 | } | - | ||||||||||||
127 | - | |||||||||||||
128 | - | |||||||||||||
129 | - | |||||||||||||
130 | void *X509V3_EXT_d2i(X509_EXTENSION *ext) | - | ||||||||||||
131 | { | - | ||||||||||||
132 | const X509V3_EXT_METHOD *method; | - | ||||||||||||
133 | const unsigned char *p; | - | ||||||||||||
134 | ASN1_STRING *extvalue; | - | ||||||||||||
135 | int extlen; | - | ||||||||||||
136 | - | |||||||||||||
137 | if ((
| 0-100504 | ||||||||||||
138 | ((void *)0)
| 0-100504 | ||||||||||||
139 | ) | - | ||||||||||||
140 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||
141 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||
142 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||
143 | extvalue = X509_EXTENSION_get_data(ext); | - | ||||||||||||
144 | p = ASN1_STRING_get0_data(extvalue); | - | ||||||||||||
145 | extlen = ASN1_STRING_length(extvalue); | - | ||||||||||||
146 | if (method->it
| 9-100495 | ||||||||||||
147 | return executed 100495 times by 1 test: ASN1_item_d2i(return ASN1_item_d2i( ((void *)0) , &p, extlen, (method->it)); Executed by:
executed 100495 times by 1 test: return ASN1_item_d2i( ((void *)0) , &p, extlen, (method->it)); Executed by:
| 100495 | ||||||||||||
148 | ((void *)0) executed 100495 times by 1 test: return ASN1_item_d2i( ((void *)0) , &p, extlen, (method->it)); Executed by:
| 100495 | ||||||||||||
149 | , &p, extlen, (method->it)); executed 100495 times by 1 test: return ASN1_item_d2i( ((void *)0) , &p, extlen, (method->it)); Executed by:
| 100495 | ||||||||||||
150 | return executed 9 times by 1 test: method->d2i(return method->d2i( ((void *)0) , &p, extlen); Executed by:
executed 9 times by 1 test: return method->d2i( ((void *)0) , &p, extlen); Executed by:
| 9 | ||||||||||||
151 | ((void *)0) executed 9 times by 1 test: return method->d2i( ((void *)0) , &p, extlen); Executed by:
| 9 | ||||||||||||
152 | , &p, extlen); executed 9 times by 1 test: return method->d2i( ((void *)0) , &p, extlen); Executed by:
| 9 | ||||||||||||
153 | } | - | ||||||||||||
154 | void *X509V3_get_d2i(const struct stack_st_X509_EXTENSION *x, int nid, int *crit, | - | ||||||||||||
155 | int *idx) | - | ||||||||||||
156 | { | - | ||||||||||||
157 | int lastpos, i; | - | ||||||||||||
158 | X509_EXTENSION *ex, *found_ex = | - | ||||||||||||
159 | ((void *)0) | - | ||||||||||||
160 | ; | - | ||||||||||||
161 | - | |||||||||||||
162 | if (!x
| 99539-294133 | ||||||||||||
163 | if (idx
| 0-99539 | ||||||||||||
164 | * never executed: idx = -1;*idx = -1; never executed: *idx = -1; | 0 | ||||||||||||
165 | if (crit
| 14114-85425 | ||||||||||||
166 | * executed 14114 times by 1 test: crit = -1;*crit = -1; Executed by:
executed 14114 times by 1 test: *crit = -1; Executed by:
| 14114 | ||||||||||||
167 | return executed 99539 times by 1 test: return ((void *)0) ; Executed by:
executed 99539 times by 1 test: return ((void *)0) ; Executed by:
| 99539 | ||||||||||||
168 | ((void *)0) executed 99539 times by 1 test: return ((void *)0) ; Executed by:
| 99539 | ||||||||||||
169 | ; executed 99539 times by 1 test: return ((void *)0) ; Executed by:
| 99539 | ||||||||||||
170 | } | - | ||||||||||||
171 | if (idx
| 0-294133 | ||||||||||||
172 | lastpos = *idx + 1; never executed: lastpos = *idx + 1; | 0 | ||||||||||||
173 | else | - | ||||||||||||
174 | lastpos = 0; executed 294133 times by 1 test: lastpos = 0; Executed by:
| 294133 | ||||||||||||
175 | if (lastpos < 0
| 0-294133 | ||||||||||||
176 | lastpos = 0; never executed: lastpos = 0; | 0 | ||||||||||||
177 | for (i = lastpos; i < sk_X509_EXTENSION_num(x)
| 292772-920576 | ||||||||||||
178 | ex = sk_X509_EXTENSION_value(x, i); | - | ||||||||||||
179 | if (OBJ_obj2nid(X509_EXTENSION_get_object(ex)) == nid
| 103213-817363 | ||||||||||||
180 | if (idx
| 0-103213 | ||||||||||||
181 | *idx = i; | - | ||||||||||||
182 | found_ex = ex; | - | ||||||||||||
183 | break; never executed: break; | 0 | ||||||||||||
184 | } else if (found_ex
| 1361-101852 | ||||||||||||
185 | - | |||||||||||||
186 | if (crit
| 418-943 | ||||||||||||
187 | * executed 418 times by 1 test: crit = -2;*crit = -2; Executed by:
executed 418 times by 1 test: *crit = -2; Executed by:
| 418 | ||||||||||||
188 | return executed 1361 times by 1 test: return ((void *)0) ; Executed by:
executed 1361 times by 1 test: return ((void *)0) ; Executed by:
| 1361 | ||||||||||||
189 | ((void *)0) executed 1361 times by 1 test: return ((void *)0) ; Executed by:
| 1361 | ||||||||||||
190 | ; executed 1361 times by 1 test: return ((void *)0) ; Executed by:
| 1361 | ||||||||||||
191 | } | - | ||||||||||||
192 | found_ex = ex; | - | ||||||||||||
193 | } executed 101852 times by 1 test: end of block Executed by:
| 101852 | ||||||||||||
194 | } executed 919215 times by 1 test: end of block Executed by:
| 919215 | ||||||||||||
195 | if (found_ex
| 100491-192281 | ||||||||||||
196 | - | |||||||||||||
197 | if (crit
| 5850-94641 | ||||||||||||
198 | * executed 5850 times by 1 test: crit = X509_EXTENSION_get_critical(found_ex);*crit = X509_EXTENSION_get_critical(found_ex); Executed by:
executed 5850 times by 1 test: *crit = X509_EXTENSION_get_critical(found_ex); Executed by:
| 5850 | ||||||||||||
199 | return executed 100491 times by 1 test: X509V3_EXT_d2i(found_ex);return X509V3_EXT_d2i(found_ex); Executed by:
executed 100491 times by 1 test: return X509V3_EXT_d2i(found_ex); Executed by:
| 100491 | ||||||||||||
200 | } | - | ||||||||||||
201 | - | |||||||||||||
202 | - | |||||||||||||
203 | if (idx
| 0-192281 | ||||||||||||
204 | * never executed: idx = -1;*idx = -1; never executed: *idx = -1; | 0 | ||||||||||||
205 | if (crit
| 20272-172009 | ||||||||||||
206 | * executed 20272 times by 1 test: crit = -1;*crit = -1; Executed by:
executed 20272 times by 1 test: *crit = -1; Executed by:
| 20272 | ||||||||||||
207 | return executed 192281 times by 1 test: return ((void *)0) ; Executed by:
executed 192281 times by 1 test: return ((void *)0) ; Executed by:
| 192281 | ||||||||||||
208 | ((void *)0) executed 192281 times by 1 test: return ((void *)0) ; Executed by:
| 192281 | ||||||||||||
209 | ; executed 192281 times by 1 test: return ((void *)0) ; Executed by:
| 192281 | ||||||||||||
210 | } | - | ||||||||||||
211 | - | |||||||||||||
212 | - | |||||||||||||
213 | - | |||||||||||||
214 | - | |||||||||||||
215 | - | |||||||||||||
216 | - | |||||||||||||
217 | - | |||||||||||||
218 | int X509V3_add1_i2d(struct stack_st_X509_EXTENSION **x, int nid, void *value, | - | ||||||||||||
219 | int crit, unsigned long flags) | - | ||||||||||||
220 | { | - | ||||||||||||
221 | int errcode, extidx = -1; | - | ||||||||||||
222 | X509_EXTENSION *ext = | - | ||||||||||||
223 | ((void *)0) | - | ||||||||||||
224 | , *extmp; | - | ||||||||||||
225 | struct stack_st_X509_EXTENSION *ret = | - | ||||||||||||
226 | ((void *)0) | - | ||||||||||||
227 | ; | - | ||||||||||||
228 | unsigned long ext_op = flags & 0xfL; | - | ||||||||||||
229 | - | |||||||||||||
230 | - | |||||||||||||
231 | - | |||||||||||||
232 | - | |||||||||||||
233 | - | |||||||||||||
234 | if (ext_op != 1L
| 0-103 | ||||||||||||
235 | extidx = X509v3_get_ext_by_NID(*x, nid, -1); executed 103 times by 1 test: extidx = X509v3_get_ext_by_NID(*x, nid, -1); Executed by:
| 103 | ||||||||||||
236 | - | |||||||||||||
237 | - | |||||||||||||
238 | if (extidx >= 0
| 0-103 | ||||||||||||
239 | - | |||||||||||||
240 | if (ext_op == 4L
| 0 | ||||||||||||
241 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||
242 | - | |||||||||||||
243 | if (ext_op == 0L
| 0 | ||||||||||||
244 | errcode = 145; | - | ||||||||||||
245 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||
246 | } | - | ||||||||||||
247 | - | |||||||||||||
248 | if (ext_op == 5L
| 0 | ||||||||||||
249 | if (!sk_X509_EXTENSION_delete(*x, extidx)
| 0 | ||||||||||||
250 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
251 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||
252 | } | - | ||||||||||||
253 | } never executed: else {end of block | 0 | ||||||||||||
254 | - | |||||||||||||
255 | - | |||||||||||||
256 | - | |||||||||||||
257 | if ((
| 0-103 | ||||||||||||
258 | (
| 0-103 | ||||||||||||
259 | errcode = 102; | - | ||||||||||||
260 | goto never executed: err;goto err; never executed: goto err; | 0 | ||||||||||||
261 | } | - | ||||||||||||
262 | } executed 103 times by 1 test: end of block Executed by:
| 103 | ||||||||||||
263 | - | |||||||||||||
264 | - | |||||||||||||
265 | - | |||||||||||||
266 | - | |||||||||||||
267 | - | |||||||||||||
268 | - | |||||||||||||
269 | ext = X509V3_EXT_i2d(nid, crit, value); | - | ||||||||||||
270 | - | |||||||||||||
271 | if (!ext
| 0-103 | ||||||||||||
272 | ERR_put_error(34,(140),(144),__FILE__,269) | - | ||||||||||||
273 | ; | - | ||||||||||||
274 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
275 | } | - | ||||||||||||
276 | - | |||||||||||||
277 | - | |||||||||||||
278 | if (extidx >= 0
| 0-103 | ||||||||||||
279 | extmp = sk_X509_EXTENSION_value(*x, extidx); | - | ||||||||||||
280 | X509_EXTENSION_free(extmp); | - | ||||||||||||
281 | if (!sk_X509_EXTENSION_set(*x, extidx, ext)
| 0 | ||||||||||||
282 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
283 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||
284 | } | - | ||||||||||||
285 | - | |||||||||||||
286 | ret = *x; | - | ||||||||||||
287 | if (*
| 0-103 | ||||||||||||
288 | ((void *)0)
| 0-103 | ||||||||||||
289 | - | |||||||||||||
290 | && (
| 0-103 | ||||||||||||
291 | ((void *)0)
| 0-103 | ||||||||||||
292 | ) | - | ||||||||||||
293 | goto never executed: m_fail;goto m_fail; never executed: goto m_fail; | 0 | ||||||||||||
294 | if (!sk_X509_EXTENSION_push(ret, ext)
| 0-103 | ||||||||||||
295 | goto never executed: m_fail;goto m_fail; never executed: goto m_fail; | 0 | ||||||||||||
296 | - | |||||||||||||
297 | *x = ret; | - | ||||||||||||
298 | return executed 103 times by 1 test: 1;return 1; Executed by:
executed 103 times by 1 test: return 1; Executed by:
| 103 | ||||||||||||
299 | - | |||||||||||||
300 | m_fail: | - | ||||||||||||
301 | - | |||||||||||||
302 | if (ret != *x
| 0 | ||||||||||||
303 | sk_X509_EXTENSION_free(ret); never executed: sk_X509_EXTENSION_free(ret); | 0 | ||||||||||||
304 | X509_EXTENSION_free(ext); | - | ||||||||||||
305 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
306 | - | |||||||||||||
307 | err: | - | ||||||||||||
308 | if (!(flags & 0x10)
| 0 | ||||||||||||
309 | ERR_put_error(34,(140),(errcode),__FILE__,301); never executed: ERR_put_error(34,(140),(errcode),__FILE__,301); | 0 | ||||||||||||
310 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
311 | } | - | ||||||||||||
Switch to Source code | Preprocessed file |