Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/engine/eng_table.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||||||||
2 | - | |||||||||||||||||||
3 | - | |||||||||||||||||||
4 | struct st_engine_pile { | - | ||||||||||||||||||
5 | - | |||||||||||||||||||
6 | int nid; | - | ||||||||||||||||||
7 | - | |||||||||||||||||||
8 | struct stack_st_ENGINE *sk; | - | ||||||||||||||||||
9 | - | |||||||||||||||||||
10 | ENGINE *funct; | - | ||||||||||||||||||
11 | - | |||||||||||||||||||
12 | - | |||||||||||||||||||
13 | - | |||||||||||||||||||
14 | int uptodate; | - | ||||||||||||||||||
15 | }; | - | ||||||||||||||||||
16 | - | |||||||||||||||||||
17 | - | |||||||||||||||||||
18 | struct st_engine_table { | - | ||||||||||||||||||
19 | struct lhash_st_ENGINE_PILE piles; | - | ||||||||||||||||||
20 | }; | - | ||||||||||||||||||
21 | - | |||||||||||||||||||
22 | typedef struct st_engine_pile_doall { | - | ||||||||||||||||||
23 | engine_table_doall_cb *cb; | - | ||||||||||||||||||
24 | void *arg; | - | ||||||||||||||||||
25 | } ENGINE_PILE_DOALL; | - | ||||||||||||||||||
26 | - | |||||||||||||||||||
27 | - | |||||||||||||||||||
28 | static unsigned int table_flags = 0; | - | ||||||||||||||||||
29 | - | |||||||||||||||||||
30 | - | |||||||||||||||||||
31 | unsigned int ENGINE_get_table_flags(void) | - | ||||||||||||||||||
32 | { | - | ||||||||||||||||||
33 | return never executed: table_flags;return table_flags; never executed: return table_flags; | 0 | ||||||||||||||||||
34 | } | - | ||||||||||||||||||
35 | - | |||||||||||||||||||
36 | void ENGINE_set_table_flags(unsigned int flags) | - | ||||||||||||||||||
37 | { | - | ||||||||||||||||||
38 | table_flags = flags; | - | ||||||||||||||||||
39 | } never executed: end of block | 0 | ||||||||||||||||||
40 | - | |||||||||||||||||||
41 | - | |||||||||||||||||||
42 | static unsigned long engine_pile_hash(const ENGINE_PILE *c) | - | ||||||||||||||||||
43 | { | - | ||||||||||||||||||
44 | return executed 20857 times by 1 test: c->nid;return c->nid; Executed by:
executed 20857 times by 1 test: return c->nid; Executed by:
| 20857 | ||||||||||||||||||
45 | } | - | ||||||||||||||||||
46 | - | |||||||||||||||||||
47 | static int engine_pile_cmp(const ENGINE_PILE *a, const ENGINE_PILE *b) | - | ||||||||||||||||||
48 | { | - | ||||||||||||||||||
49 | return executed 14801 times by 1 test: a->nid - b->nid;return a->nid - b->nid; Executed by:
executed 14801 times by 1 test: return a->nid - b->nid; Executed by:
| 14801 | ||||||||||||||||||
50 | } | - | ||||||||||||||||||
51 | - | |||||||||||||||||||
52 | static int int_table_check(ENGINE_TABLE **t, int create) | - | ||||||||||||||||||
53 | { | - | ||||||||||||||||||
54 | struct lhash_st_ENGINE_PILE *lh; | - | ||||||||||||||||||
55 | - | |||||||||||||||||||
56 | if (*
| 1101-12049 | ||||||||||||||||||
57 | return executed 12049 times by 1 test: 1;return 1; Executed by:
executed 12049 times by 1 test: return 1; Executed by:
| 12049 | ||||||||||||||||||
58 | if (!create
| 0-1101 | ||||||||||||||||||
59 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
60 | if ((
| 0-1101 | ||||||||||||||||||
61 | ((void *)0)
| 0-1101 | ||||||||||||||||||
62 | ) | - | ||||||||||||||||||
63 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||||||||
64 | *t = (ENGINE_TABLE *)lh; | - | ||||||||||||||||||
65 | return executed 1101 times by 1 test: 1;return 1; Executed by:
executed 1101 times by 1 test: return 1; Executed by:
| 1101 | ||||||||||||||||||
66 | } | - | ||||||||||||||||||
67 | - | |||||||||||||||||||
68 | - | |||||||||||||||||||
69 | - | |||||||||||||||||||
70 | - | |||||||||||||||||||
71 | - | |||||||||||||||||||
72 | int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup, | - | ||||||||||||||||||
73 | ENGINE *e, const int *nids, int num_nids, | - | ||||||||||||||||||
74 | int setdefault) | - | ||||||||||||||||||
75 | { | - | ||||||||||||||||||
76 | int ret = 0, added = 0; | - | ||||||||||||||||||
77 | ENGINE_PILE tmplate, *fnd; | - | ||||||||||||||||||
78 | CRYPTO_THREAD_write_lock(global_engine_lock); | - | ||||||||||||||||||
79 | if (!(*table)
| 0-1101 | ||||||||||||||||||
80 | added = 1; executed 1101 times by 1 test: added = 1; Executed by:
| 1101 | ||||||||||||||||||
81 | if (!int_table_check(table, 1)
| 0-1101 | ||||||||||||||||||
82 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
83 | if (added
| 0-1101 | ||||||||||||||||||
84 | - | |||||||||||||||||||
85 | engine_cleanup_add_first(cleanup); executed 1101 times by 1 test: engine_cleanup_add_first(cleanup); Executed by:
| 1101 | ||||||||||||||||||
86 | while (num_nids--
| 1101-2936 | ||||||||||||||||||
87 | tmplate.nid = *nids; | - | ||||||||||||||||||
88 | fnd = lh_ENGINE_PILE_retrieve(&(*table)->piles, &tmplate); | - | ||||||||||||||||||
89 | if (!fnd
| 0-2936 | ||||||||||||||||||
90 | fnd = CRYPTO_malloc(sizeof(*fnd), __FILE__, 100); | - | ||||||||||||||||||
91 | if (fnd ==
| 0-2936 | ||||||||||||||||||
92 | ((void *)0)
| 0-2936 | ||||||||||||||||||
93 | ) | - | ||||||||||||||||||
94 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
95 | fnd->uptodate = 1; | - | ||||||||||||||||||
96 | fnd->nid = *nids; | - | ||||||||||||||||||
97 | fnd->sk = sk_ENGINE_new_null(); | - | ||||||||||||||||||
98 | if (!fnd->sk
| 0-2936 | ||||||||||||||||||
99 | CRYPTO_free(fnd, __FILE__, 107); | - | ||||||||||||||||||
100 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
101 | } | - | ||||||||||||||||||
102 | fnd->funct = | - | ||||||||||||||||||
103 | ((void *)0) | - | ||||||||||||||||||
104 | ; | - | ||||||||||||||||||
105 | (void)lh_ENGINE_PILE_insert(&(*table)->piles, fnd); | - | ||||||||||||||||||
106 | if (lh_ENGINE_PILE_retrieve(&(*table)->piles, &tmplate) != fnd
| 0-2936 | ||||||||||||||||||
107 | sk_ENGINE_free(fnd->sk); | - | ||||||||||||||||||
108 | CRYPTO_free(fnd, __FILE__, 114); | - | ||||||||||||||||||
109 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
110 | } | - | ||||||||||||||||||
111 | } executed 2936 times by 1 test: end of block Executed by:
| 2936 | ||||||||||||||||||
112 | - | |||||||||||||||||||
113 | (void)sk_ENGINE_delete_ptr(fnd->sk, e); | - | ||||||||||||||||||
114 | - | |||||||||||||||||||
115 | - | |||||||||||||||||||
116 | - | |||||||||||||||||||
117 | if (!sk_ENGINE_push(fnd->sk, e)
| 0-2936 | ||||||||||||||||||
118 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
119 | - | |||||||||||||||||||
120 | fnd->uptodate = 0; | - | ||||||||||||||||||
121 | if (setdefault
| 0-2936 | ||||||||||||||||||
122 | if (!engine_unlocked_init(e)
| 0-2936 | ||||||||||||||||||
123 | ERR_put_error(38,(184),(109),__FILE__,130) | - | ||||||||||||||||||
124 | ; | - | ||||||||||||||||||
125 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
126 | } | - | ||||||||||||||||||
127 | if (fnd->funct
| 0-2936 | ||||||||||||||||||
128 | engine_unlocked_finish(fnd->funct, 0); never executed: engine_unlocked_finish(fnd->funct, 0); | 0 | ||||||||||||||||||
129 | fnd->funct = e; | - | ||||||||||||||||||
130 | fnd->uptodate = 1; | - | ||||||||||||||||||
131 | } executed 2936 times by 1 test: end of block Executed by:
| 2936 | ||||||||||||||||||
132 | nids++; | - | ||||||||||||||||||
133 | } executed 2936 times by 1 test: end of block Executed by:
| 2936 | ||||||||||||||||||
134 | ret = 1; | - | ||||||||||||||||||
135 | end: code before this statement executed 1101 times by 1 test: end: Executed by:
| 1101 | ||||||||||||||||||
136 | CRYPTO_THREAD_unlock(global_engine_lock); | - | ||||||||||||||||||
137 | return executed 1101 times by 1 test: ret;return ret; Executed by:
executed 1101 times by 1 test: return ret; Executed by:
| 1101 | ||||||||||||||||||
138 | } | - | ||||||||||||||||||
139 | - | |||||||||||||||||||
140 | static void int_unregister_cb(ENGINE_PILE *pile, ENGINE *e) | - | ||||||||||||||||||
141 | { | - | ||||||||||||||||||
142 | int n; | - | ||||||||||||||||||
143 | - | |||||||||||||||||||
144 | while ((
| 0 | ||||||||||||||||||
145 | (void)sk_ENGINE_delete(pile->sk, n); | - | ||||||||||||||||||
146 | pile->uptodate = 0; | - | ||||||||||||||||||
147 | } never executed: end of block | 0 | ||||||||||||||||||
148 | if (pile->funct == e
| 0 | ||||||||||||||||||
149 | engine_unlocked_finish(e, 0); | - | ||||||||||||||||||
150 | pile->funct = | - | ||||||||||||||||||
151 | ((void *)0) | - | ||||||||||||||||||
152 | ; | - | ||||||||||||||||||
153 | } never executed: end of block | 0 | ||||||||||||||||||
154 | } never executed: end of block | 0 | ||||||||||||||||||
155 | - | |||||||||||||||||||
156 | static inline void lh_ENGINE_PILE_doall_ENGINE(struct lhash_st_ENGINE_PILE *lh, void (*fn)(ENGINE_PILE *, ENGINE *), ENGINE *arg) { OPENSSL_LH_doall_arg((OPENSSL_LHASH *)lh, (OPENSSL_LH_DOALL_FUNCARG)fn, (void *)arg); } never executed: struct lhash_st_ENGINE_PILE;end of block | 0 | ||||||||||||||||||
157 | - | |||||||||||||||||||
158 | void engine_table_unregister(ENGINE_TABLE **table, ENGINE *e) | - | ||||||||||||||||||
159 | { | - | ||||||||||||||||||
160 | CRYPTO_THREAD_write_lock(global_engine_lock); | - | ||||||||||||||||||
161 | if (int_table_check(table, 0)
| 0 | ||||||||||||||||||
162 | lh_ENGINE_PILE_doall_ENGINE(&(*table)->piles, int_unregister_cb, e); never executed: lh_ENGINE_PILE_doall_ENGINE(&(*table)->piles, int_unregister_cb, e); | 0 | ||||||||||||||||||
163 | CRYPTO_THREAD_unlock(global_engine_lock); | - | ||||||||||||||||||
164 | } never executed: end of block | 0 | ||||||||||||||||||
165 | - | |||||||||||||||||||
166 | static void int_cleanup_cb_doall(ENGINE_PILE *p) | - | ||||||||||||||||||
167 | { | - | ||||||||||||||||||
168 | if (!p
| 0-2936 | ||||||||||||||||||
169 | return; never executed: return; | 0 | ||||||||||||||||||
170 | sk_ENGINE_free(p->sk); | - | ||||||||||||||||||
171 | if (p->funct
| 0-2936 | ||||||||||||||||||
172 | engine_unlocked_finish(p->funct, 0); executed 2936 times by 1 test: engine_unlocked_finish(p->funct, 0); Executed by:
| 2936 | ||||||||||||||||||
173 | CRYPTO_free(p, __FILE__, 177); | - | ||||||||||||||||||
174 | } executed 2936 times by 1 test: end of block Executed by:
| 2936 | ||||||||||||||||||
175 | - | |||||||||||||||||||
176 | void engine_table_cleanup(ENGINE_TABLE **table) | - | ||||||||||||||||||
177 | { | - | ||||||||||||||||||
178 | CRYPTO_THREAD_write_lock(global_engine_lock); | - | ||||||||||||||||||
179 | if (*
| 0-1101 | ||||||||||||||||||
180 | lh_ENGINE_PILE_doall(&(*table)->piles, int_cleanup_cb_doall); | - | ||||||||||||||||||
181 | lh_ENGINE_PILE_free(&(*table)->piles); | - | ||||||||||||||||||
182 | *table = | - | ||||||||||||||||||
183 | ((void *)0) | - | ||||||||||||||||||
184 | ; | - | ||||||||||||||||||
185 | } executed 1101 times by 1 test: end of block Executed by:
| 1101 | ||||||||||||||||||
186 | CRYPTO_THREAD_unlock(global_engine_lock); | - | ||||||||||||||||||
187 | } executed 1101 times by 1 test: end of block Executed by:
| 1101 | ||||||||||||||||||
188 | - | |||||||||||||||||||
189 | - | |||||||||||||||||||
190 | - | |||||||||||||||||||
191 | ENGINE *engine_table_select(ENGINE_TABLE **table, int nid) | - | ||||||||||||||||||
192 | - | |||||||||||||||||||
193 | - | |||||||||||||||||||
194 | - | |||||||||||||||||||
195 | - | |||||||||||||||||||
196 | { | - | ||||||||||||||||||
197 | ENGINE *ret = | - | ||||||||||||||||||
198 | ((void *)0) | - | ||||||||||||||||||
199 | ; | - | ||||||||||||||||||
200 | ENGINE_PILE tmplate, *fnd = | - | ||||||||||||||||||
201 | ((void *)0) | - | ||||||||||||||||||
202 | ; | - | ||||||||||||||||||
203 | int initres, loop = 0; | - | ||||||||||||||||||
204 | - | |||||||||||||||||||
205 | if (!(*table)
| 12049-4142606 | ||||||||||||||||||
206 | - | |||||||||||||||||||
207 | - | |||||||||||||||||||
208 | - | |||||||||||||||||||
209 | - | |||||||||||||||||||
210 | return executed 4141226 times by 3 tests: return ((void *)0) ; Executed by:
executed 4141226 times by 3 tests: return ((void *)0) ; Executed by:
| 4141226 | ||||||||||||||||||
211 | ((void *)0) executed 4141226 times by 3 tests: return ((void *)0) ; Executed by:
| 4141226 | ||||||||||||||||||
212 | ; executed 4141226 times by 3 tests: return ((void *)0) ; Executed by:
| 4141226 | ||||||||||||||||||
213 | } | - | ||||||||||||||||||
214 | ERR_set_mark(); | - | ||||||||||||||||||
215 | CRYPTO_THREAD_write_lock(global_engine_lock); | - | ||||||||||||||||||
216 | - | |||||||||||||||||||
217 | - | |||||||||||||||||||
218 | - | |||||||||||||||||||
219 | - | |||||||||||||||||||
220 | if (!int_table_check(table, 0)
| 0-12049 | ||||||||||||||||||
221 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
222 | tmplate.nid = nid; | - | ||||||||||||||||||
223 | fnd = lh_ENGINE_PILE_retrieve(&(*table)->piles, &tmplate); | - | ||||||||||||||||||
224 | if (!fnd
| 184-11865 | ||||||||||||||||||
225 | goto executed 184 times by 1 test: end;goto end; Executed by:
executed 184 times by 1 test: goto end; Executed by:
| 184 | ||||||||||||||||||
226 | if (fnd->funct
| 0-11865 | ||||||||||||||||||
227 | - | |||||||||||||||||||
228 | - | |||||||||||||||||||
229 | - | |||||||||||||||||||
230 | - | |||||||||||||||||||
231 | ret = fnd->funct; | - | ||||||||||||||||||
232 | goto executed 11865 times by 1 test: end;goto end; Executed by:
executed 11865 times by 1 test: goto end; Executed by:
| 11865 | ||||||||||||||||||
233 | } | - | ||||||||||||||||||
234 | if (fnd->uptodate
| 0 | ||||||||||||||||||
235 | ret = fnd->funct; | - | ||||||||||||||||||
236 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
237 | } | - | ||||||||||||||||||
238 | trynext: code before this statement never executed: trynext: | 0 | ||||||||||||||||||
239 | ret = sk_ENGINE_value(fnd->sk, loop++); | - | ||||||||||||||||||
240 | if (!ret
| 0 | ||||||||||||||||||
241 | - | |||||||||||||||||||
242 | - | |||||||||||||||||||
243 | - | |||||||||||||||||||
244 | - | |||||||||||||||||||
245 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
246 | } | - | ||||||||||||||||||
247 | - | |||||||||||||||||||
248 | if ((
| 0 | ||||||||||||||||||
249 | initres = engine_unlocked_init(ret); never executed: initres = engine_unlocked_init(ret); | 0 | ||||||||||||||||||
250 | else | - | ||||||||||||||||||
251 | initres = 0; never executed: initres = 0; | 0 | ||||||||||||||||||
252 | if (initres
| 0 | ||||||||||||||||||
253 | - | |||||||||||||||||||
254 | if ((
| 0 | ||||||||||||||||||
255 | - | |||||||||||||||||||
256 | if (fnd->funct
| 0 | ||||||||||||||||||
257 | engine_unlocked_finish(fnd->funct, 0); never executed: engine_unlocked_finish(fnd->funct, 0); | 0 | ||||||||||||||||||
258 | fnd->funct = ret; | - | ||||||||||||||||||
259 | - | |||||||||||||||||||
260 | - | |||||||||||||||||||
261 | - | |||||||||||||||||||
262 | - | |||||||||||||||||||
263 | } never executed: end of block | 0 | ||||||||||||||||||
264 | - | |||||||||||||||||||
265 | - | |||||||||||||||||||
266 | - | |||||||||||||||||||
267 | - | |||||||||||||||||||
268 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||||||||
269 | } | - | ||||||||||||||||||
270 | goto never executed: trynext;goto trynext; never executed: goto trynext; | 0 | ||||||||||||||||||
271 | end: | - | ||||||||||||||||||
272 | - | |||||||||||||||||||
273 | - | |||||||||||||||||||
274 | - | |||||||||||||||||||
275 | - | |||||||||||||||||||
276 | if (fnd
| 184-11865 | ||||||||||||||||||
277 | fnd->uptodate = 1; executed 11865 times by 1 test: fnd->uptodate = 1; Executed by:
| 11865 | ||||||||||||||||||
278 | CRYPTO_THREAD_unlock(global_engine_lock); | - | ||||||||||||||||||
279 | - | |||||||||||||||||||
280 | - | |||||||||||||||||||
281 | - | |||||||||||||||||||
282 | - | |||||||||||||||||||
283 | ERR_pop_to_mark(); | - | ||||||||||||||||||
284 | return executed 12049 times by 1 test: ret;return ret; Executed by:
executed 12049 times by 1 test: return ret; Executed by:
| 12049 | ||||||||||||||||||
285 | } | - | ||||||||||||||||||
286 | - | |||||||||||||||||||
287 | - | |||||||||||||||||||
288 | - | |||||||||||||||||||
289 | static void int_dall(const ENGINE_PILE *pile, ENGINE_PILE_DOALL *dall) | - | ||||||||||||||||||
290 | { | - | ||||||||||||||||||
291 | dall->cb(pile->nid, pile->sk, pile->funct, dall->arg); | - | ||||||||||||||||||
292 | } never executed: end of block | 0 | ||||||||||||||||||
293 | - | |||||||||||||||||||
294 | static inline void lh_ENGINE_PILE_doall_ENGINE_PILE_DOALL(struct lhash_st_ENGINE_PILE *lh, void (*fn)(const ENGINE_PILE *, ENGINE_PILE_DOALL *), ENGINE_PILE_DOALL *arg) { OPENSSL_LH_doall_arg((OPENSSL_LHASH *)lh, (OPENSSL_LH_DOALL_FUNCARG)fn, (void *)arg); } never executed: struct lhash_st_ENGINE_PILE;end of block | 0 | ||||||||||||||||||
295 | - | |||||||||||||||||||
296 | void engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb, | - | ||||||||||||||||||
297 | void *arg) | - | ||||||||||||||||||
298 | { | - | ||||||||||||||||||
299 | ENGINE_PILE_DOALL dall; | - | ||||||||||||||||||
300 | dall.cb = cb; | - | ||||||||||||||||||
301 | dall.arg = arg; | - | ||||||||||||||||||
302 | if (table
| 0-9796 | ||||||||||||||||||
303 | lh_ENGINE_PILE_doall_ENGINE_PILE_DOALL(&table->piles, int_dall, &dall); never executed: lh_ENGINE_PILE_doall_ENGINE_PILE_DOALL(&table->piles, int_dall, &dall); | 0 | ||||||||||||||||||
304 | } executed 9796 times by 1 test: end of block Executed by:
| 9796 | ||||||||||||||||||
Switch to Source code | Preprocessed file |