Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/crypto/bio/bss_conn.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | typedef struct bio_connect_st { | - | ||||||||||||
6 | int state; | - | ||||||||||||
7 | int connect_family; | - | ||||||||||||
8 | char *param_hostname; | - | ||||||||||||
9 | char *param_service; | - | ||||||||||||
10 | int connect_mode; | - | ||||||||||||
11 | - | |||||||||||||
12 | BIO_ADDRINFO *addr_first; | - | ||||||||||||
13 | const BIO_ADDRINFO *addr_iter; | - | ||||||||||||
14 | BIO_info_cb *info_callback; | - | ||||||||||||
15 | } BIO_CONNECT; | - | ||||||||||||
16 | - | |||||||||||||
17 | static int conn_write(BIO *h, const char *buf, int num); | - | ||||||||||||
18 | static int conn_read(BIO *h, char *buf, int size); | - | ||||||||||||
19 | static int conn_puts(BIO *h, const char *str); | - | ||||||||||||
20 | static long conn_ctrl(BIO *h, int cmd, long arg1, void *arg2); | - | ||||||||||||
21 | static int conn_new(BIO *h); | - | ||||||||||||
22 | static int conn_free(BIO *data); | - | ||||||||||||
23 | static long conn_callback_ctrl(BIO *h, int cmd, BIO_info_cb *); | - | ||||||||||||
24 | - | |||||||||||||
25 | static int conn_state(BIO *b, BIO_CONNECT *c); | - | ||||||||||||
26 | static void conn_close_socket(BIO *data); | - | ||||||||||||
27 | BIO_CONNECT *BIO_CONNECT_new(void); | - | ||||||||||||
28 | void BIO_CONNECT_free(BIO_CONNECT *a); | - | ||||||||||||
29 | static const BIO_METHOD methods_connectp = { | - | ||||||||||||
30 | (12|0x0400|0x0100), | - | ||||||||||||
31 | "socket connect", | - | ||||||||||||
32 | - | |||||||||||||
33 | bwrite_conv, | - | ||||||||||||
34 | conn_write, | - | ||||||||||||
35 | - | |||||||||||||
36 | bread_conv, | - | ||||||||||||
37 | conn_read, | - | ||||||||||||
38 | conn_puts, | - | ||||||||||||
39 | - | |||||||||||||
40 | ((void *)0) | - | ||||||||||||
41 | , | - | ||||||||||||
42 | conn_ctrl, | - | ||||||||||||
43 | conn_new, | - | ||||||||||||
44 | conn_free, | - | ||||||||||||
45 | conn_callback_ctrl, | - | ||||||||||||
46 | }; | - | ||||||||||||
47 | - | |||||||||||||
48 | static int conn_state(BIO *b, BIO_CONNECT *c) | - | ||||||||||||
49 | { | - | ||||||||||||
50 | int ret = -1, i; | - | ||||||||||||
51 | BIO_info_cb *cb = | - | ||||||||||||
52 | ((void *)0) | - | ||||||||||||
53 | ; | - | ||||||||||||
54 | - | |||||||||||||
55 | if (c->info_callback !=
| 0-4 | ||||||||||||
56 | ((void *)0)
| 0-4 | ||||||||||||
57 | ) | - | ||||||||||||
58 | cb = c->info_callback; never executed: cb = c->info_callback; | 0 | ||||||||||||
59 | - | |||||||||||||
60 | for (;;) { | - | ||||||||||||
61 | switch (c->state) { | - | ||||||||||||
62 | case executed 2 times by 1 test: 1:case 1: Executed by:
executed 2 times by 1 test: case 1: Executed by:
| 2 | ||||||||||||
63 | if (c->param_hostname ==
| 0-2 | ||||||||||||
64 | ((void *)0)
| 0-2 | ||||||||||||
65 | && c->param_service ==
| 0-2 | ||||||||||||
66 | ((void *)0)
| 0-2 | ||||||||||||
67 | ) { | - | ||||||||||||
68 | ERR_put_error(32,(115),(144),__FILE__,87); | - | ||||||||||||
69 | ERR_add_error_data(4, | - | ||||||||||||
70 | "hostname=", c->param_hostname, | - | ||||||||||||
71 | " service=", c->param_service); | - | ||||||||||||
72 | goto never executed: exit_loop;goto exit_loop; never executed: goto exit_loop; | 0 | ||||||||||||
73 | } | - | ||||||||||||
74 | c->state = 2; | - | ||||||||||||
75 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||
76 | - | |||||||||||||
77 | case executed 2 times by 1 test: 2:case 2: Executed by:
executed 2 times by 1 test: case 2: Executed by:
| 2 | ||||||||||||
78 | { | - | ||||||||||||
79 | int family = | - | ||||||||||||
80 | 0 | - | ||||||||||||
81 | ; | - | ||||||||||||
82 | switch (c->connect_family) { | - | ||||||||||||
83 | case executed 1 time by 1 test: 6:case 6: Executed by:
executed 1 time by 1 test: case 6: Executed by:
| 1 | ||||||||||||
84 | if (1) { | - | ||||||||||||
85 | - | |||||||||||||
86 | - | |||||||||||||
87 | - | |||||||||||||
88 | - | |||||||||||||
89 | family = | - | ||||||||||||
90 | 10 | - | ||||||||||||
91 | ; | - | ||||||||||||
92 | } executed 1 time by 1 test: else {end of block Executed by:
dead code: { ERR_put_error(32,(115),(145),__FILE__,109); goto exit_loop; } | - | ||||||||||||
93 | - | |||||||||||||
94 | ERR_put_error(32,(115),(145),__FILE__,109); dead code: { ERR_put_error(32,(115),(145),__FILE__,109); goto exit_loop; } | - | ||||||||||||
95 | goto exit_loop; dead code: { ERR_put_error(32,(115),(145),__FILE__,109); goto exit_loop; } | - | ||||||||||||
96 | } dead code: { ERR_put_error(32,(115),(145),__FILE__,109); goto exit_loop; } | - | ||||||||||||
97 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||
98 | case executed 1 time by 1 test: 4:case 4: Executed by:
executed 1 time by 1 test: case 4: Executed by:
| 1 | ||||||||||||
99 | family = | - | ||||||||||||
100 | 2 | - | ||||||||||||
101 | ; | - | ||||||||||||
102 | break; executed 1 time by 1 test: break; Executed by:
| 1 | ||||||||||||
103 | case never executed: 256:case 256: never executed: case 256: | 0 | ||||||||||||
104 | family = | - | ||||||||||||
105 | 0 | - | ||||||||||||
106 | ; | - | ||||||||||||
107 | break; never executed: break; | 0 | ||||||||||||
108 | default never executed: :default: never executed: default: | 0 | ||||||||||||
109 | ERR_put_error(32,(115),(146),__FILE__,120); | - | ||||||||||||
110 | goto never executed: exit_loop;goto exit_loop; never executed: goto exit_loop; | 0 | ||||||||||||
111 | } | - | ||||||||||||
112 | if (BIO_lookup(c->param_hostname, c->param_service,
| 0-2 | ||||||||||||
113 | BIO_LOOKUP_CLIENT,
| 0-2 | ||||||||||||
114 | family,
| 0-2 | ||||||||||||
115 | SOCK_STREAM
| 0-2 | ||||||||||||
116 | , &c->addr_first) == 0
| 0-2 | ||||||||||||
117 | goto never executed: exit_loop;goto exit_loop; never executed: goto exit_loop; | 0 | ||||||||||||
118 | } | - | ||||||||||||
119 | if (c->addr_first ==
| 0-2 | ||||||||||||
120 | ((void *)0)
| 0-2 | ||||||||||||
121 | ) { | - | ||||||||||||
122 | ERR_put_error(32,(115),(142),__FILE__,129); | - | ||||||||||||
123 | goto never executed: exit_loop;goto exit_loop; never executed: goto exit_loop; | 0 | ||||||||||||
124 | } | - | ||||||||||||
125 | c->addr_iter = c->addr_first; | - | ||||||||||||
126 | c->state = 3; | - | ||||||||||||
127 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||
128 | - | |||||||||||||
129 | case executed 2 times by 1 test: 3:case 3: Executed by:
executed 2 times by 1 test: case 3: Executed by:
| 2 | ||||||||||||
130 | ret = BIO_socket(BIO_ADDRINFO_family(c->addr_iter), | - | ||||||||||||
131 | BIO_ADDRINFO_socktype(c->addr_iter), | - | ||||||||||||
132 | BIO_ADDRINFO_protocol(c->addr_iter), 0); | - | ||||||||||||
133 | if (ret == (int)(-1)
| 0-2 | ||||||||||||
134 | ERR_put_error(2,(4),( | - | ||||||||||||
135 | (*__errno_location ()) | - | ||||||||||||
136 | ),__FILE__,141); | - | ||||||||||||
137 | ERR_add_error_data(4, | - | ||||||||||||
138 | "hostname=", c->param_hostname, | - | ||||||||||||
139 | " service=", c->param_service); | - | ||||||||||||
140 | ERR_put_error(32,(115),(118),__FILE__,145); | - | ||||||||||||
141 | goto never executed: exit_loop;goto exit_loop; never executed: goto exit_loop; | 0 | ||||||||||||
142 | } | - | ||||||||||||
143 | b->num = ret; | - | ||||||||||||
144 | c->state = 4; | - | ||||||||||||
145 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||
146 | - | |||||||||||||
147 | case executed 2 times by 1 test: 4:case 4: Executed by:
executed 2 times by 1 test: case 4: Executed by:
| 2 | ||||||||||||
148 | BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08)); | - | ||||||||||||
149 | ret = BIO_connect(b->num, BIO_ADDRINFO_address(c->addr_iter), | - | ||||||||||||
150 | 0x04 | c->connect_mode); | - | ||||||||||||
151 | b->retry_reason = 0; | - | ||||||||||||
152 | if (ret == 0
| 0-2 | ||||||||||||
153 | if (BIO_sock_should_retry(ret)
| 0-2 | ||||||||||||
154 | BIO_set_flags(b, (0x04|0x08)); | - | ||||||||||||
155 | c->state = 6; | - | ||||||||||||
156 | b->retry_reason = 0x02; | - | ||||||||||||
157 | ERR_clear_error(); | - | ||||||||||||
158 | } executed 2 times by 1 test: else if ((end of block Executed by:
| 0-2 | ||||||||||||
159 | !=
| 0 | ||||||||||||
160 | ((void *)0)
| 0 | ||||||||||||
161 | ) { | - | ||||||||||||
162 | - | |||||||||||||
163 | - | |||||||||||||
164 | - | |||||||||||||
165 | BIO_closesocket(b->num); | - | ||||||||||||
166 | c->state = 3; | - | ||||||||||||
167 | ERR_clear_error(); | - | ||||||||||||
168 | break; never executed: break; | 0 | ||||||||||||
169 | } else { | - | ||||||||||||
170 | ERR_put_error(2,(2),( | - | ||||||||||||
171 | (*__errno_location ()) | - | ||||||||||||
172 | ),__FILE__,173); | - | ||||||||||||
173 | ERR_add_error_data(4, | - | ||||||||||||
174 | "hostname=", c->param_hostname, | - | ||||||||||||
175 | " service=", c->param_service); | - | ||||||||||||
176 | ERR_put_error(32,(115),(103),__FILE__,177); | - | ||||||||||||
177 | } never executed: end of block | 0 | ||||||||||||
178 | goto executed 2 times by 1 test: exit_loop;goto exit_loop; Executed by:
executed 2 times by 1 test: goto exit_loop; Executed by:
| 2 | ||||||||||||
179 | } else { | - | ||||||||||||
180 | c->state = 5; | - | ||||||||||||
181 | } never executed: end of block | 0 | ||||||||||||
182 | break; never executed: break; | 0 | ||||||||||||
183 | - | |||||||||||||
184 | case executed 2 times by 1 test: 6:case 6: Executed by:
executed 2 times by 1 test: case 6: Executed by:
| 2 | ||||||||||||
185 | i = BIO_sock_error(b->num); | - | ||||||||||||
186 | if (i
| 0-2 | ||||||||||||
187 | BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08)); | - | ||||||||||||
188 | ERR_put_error(2,(2),(i),__FILE__,189); | - | ||||||||||||
189 | ERR_add_error_data(4, | - | ||||||||||||
190 | "hostname=", c->param_hostname, | - | ||||||||||||
191 | " service=", c->param_service); | - | ||||||||||||
192 | ERR_put_error(32,(115),(110),__FILE__,193); | - | ||||||||||||
193 | ret = 0; | - | ||||||||||||
194 | goto never executed: exit_loop;goto exit_loop; never executed: goto exit_loop; | 0 | ||||||||||||
195 | } else | - | ||||||||||||
196 | c->state = 5; executed 2 times by 1 test: c->state = 5; Executed by:
| 2 | ||||||||||||
197 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||
198 | - | |||||||||||||
199 | case executed 2 times by 1 test: 5:case 5: Executed by:
executed 2 times by 1 test: case 5: Executed by:
| 2 | ||||||||||||
200 | ret = 1; | - | ||||||||||||
201 | goto executed 2 times by 1 test: exit_loop;goto exit_loop; Executed by:
executed 2 times by 1 test: goto exit_loop; Executed by:
| 2 | ||||||||||||
202 | default never executed: :default: never executed: default: | 0 | ||||||||||||
203 | - | |||||||||||||
204 | goto never executed: exit_loop;goto exit_loop; never executed: goto exit_loop; | 0 | ||||||||||||
205 | } | - | ||||||||||||
206 | - | |||||||||||||
207 | if (cb !=
| 0-8 | ||||||||||||
208 | ((void *)0)
| 0-8 | ||||||||||||
209 | ) { | - | ||||||||||||
210 | if ((
| 0 | ||||||||||||
211 | goto never executed: end;goto end; never executed: goto end; | 0 | ||||||||||||
212 | } never executed: end of block | 0 | ||||||||||||
213 | } executed 8 times by 1 test: end of block Executed by:
| 8 | ||||||||||||
214 | - | |||||||||||||
215 | - | |||||||||||||
216 | exit_loop: code before this statement never executed: exit_loop: | 0 | ||||||||||||
217 | if (cb !=
| 0-4 | ||||||||||||
218 | ((void *)0)
| 0-4 | ||||||||||||
219 | ) | - | ||||||||||||
220 | ret = cb((BIO *)b, c->state, ret); never executed: ret = cb((BIO *)b, c->state, ret); | 0 | ||||||||||||
221 | end: code before this statement executed 4 times by 1 test: end: Executed by:
| 4 | ||||||||||||
222 | return executed 4 times by 1 test: ret;return ret; Executed by:
executed 4 times by 1 test: return ret; Executed by:
| 4 | ||||||||||||
223 | } | - | ||||||||||||
224 | - | |||||||||||||
225 | BIO_CONNECT *BIO_CONNECT_new(void) | - | ||||||||||||
226 | { | - | ||||||||||||
227 | BIO_CONNECT *ret; | - | ||||||||||||
228 | - | |||||||||||||
229 | if ((
| 0-2 | ||||||||||||
230 | ((void *)0)
| 0-2 | ||||||||||||
231 | ) { | - | ||||||||||||
232 | ERR_put_error(32,(153),((1|64)),__FILE__,227); | - | ||||||||||||
233 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||
234 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||
235 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||
236 | } | - | ||||||||||||
237 | ret->state = 1; | - | ||||||||||||
238 | ret->connect_family = 256; | - | ||||||||||||
239 | return executed 2 times by 1 test: ret;return ret; Executed by:
executed 2 times by 1 test: return ret; Executed by:
| 2 | ||||||||||||
240 | } | - | ||||||||||||
241 | - | |||||||||||||
242 | void BIO_CONNECT_free(BIO_CONNECT *a) | - | ||||||||||||
243 | { | - | ||||||||||||
244 | if (a ==
| 0-2 | ||||||||||||
245 | ((void *)0)
| 0-2 | ||||||||||||
246 | ) | - | ||||||||||||
247 | return; never executed: return; | 0 | ||||||||||||
248 | CRYPTO_free(a->param_hostname, __FILE__, 239); | - | ||||||||||||
249 | CRYPTO_free(a->param_service, __FILE__, 240); | - | ||||||||||||
250 | BIO_ADDRINFO_free(a->addr_first); | - | ||||||||||||
251 | CRYPTO_free(a, __FILE__, 242); | - | ||||||||||||
252 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
253 | - | |||||||||||||
254 | const BIO_METHOD *BIO_s_connect(void) | - | ||||||||||||
255 | { | - | ||||||||||||
256 | return executed 2 times by 1 test: &methods_connectp;return &methods_connectp; Executed by:
executed 2 times by 1 test: return &methods_connectp; Executed by:
| 2 | ||||||||||||
257 | } | - | ||||||||||||
258 | - | |||||||||||||
259 | static int conn_new(BIO *bi) | - | ||||||||||||
260 | { | - | ||||||||||||
261 | bi->init = 0; | - | ||||||||||||
262 | bi->num = (int)(-1); | - | ||||||||||||
263 | bi->flags = 0; | - | ||||||||||||
264 | if ((
| 0-2 | ||||||||||||
265 | ((void *)0)
| 0-2 | ||||||||||||
266 | ) | - | ||||||||||||
267 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
268 | else | - | ||||||||||||
269 | return executed 2 times by 1 test: 1;return 1; Executed by:
executed 2 times by 1 test: return 1; Executed by:
| 2 | ||||||||||||
270 | } | - | ||||||||||||
271 | - | |||||||||||||
272 | static void conn_close_socket(BIO *bio) | - | ||||||||||||
273 | { | - | ||||||||||||
274 | BIO_CONNECT *c; | - | ||||||||||||
275 | - | |||||||||||||
276 | c = (BIO_CONNECT *)bio->ptr; | - | ||||||||||||
277 | if (bio->num != (int)(-1)
| 0-2 | ||||||||||||
278 | - | |||||||||||||
279 | if (c->state == 5
| 0-2 | ||||||||||||
280 | shutdown(bio->num, 2); executed 2 times by 1 test: shutdown(bio->num, 2); Executed by:
| 2 | ||||||||||||
281 | BIO_closesocket(bio->num); | - | ||||||||||||
282 | bio->num = (int)(-1); | - | ||||||||||||
283 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
284 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
285 | - | |||||||||||||
286 | static int conn_free(BIO *a) | - | ||||||||||||
287 | { | - | ||||||||||||
288 | BIO_CONNECT *data; | - | ||||||||||||
289 | - | |||||||||||||
290 | if (a ==
| 0-2 | ||||||||||||
291 | ((void *)0)
| 0-2 | ||||||||||||
292 | ) | - | ||||||||||||
293 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
294 | data = (BIO_CONNECT *)a->ptr; | - | ||||||||||||
295 | - | |||||||||||||
296 | if (a->shutdown
| 0-2 | ||||||||||||
297 | conn_close_socket(a); | - | ||||||||||||
298 | BIO_CONNECT_free(data); | - | ||||||||||||
299 | a->ptr = | - | ||||||||||||
300 | ((void *)0) | - | ||||||||||||
301 | ; | - | ||||||||||||
302 | a->flags = 0; | - | ||||||||||||
303 | a->init = 0; | - | ||||||||||||
304 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||||||||
305 | return executed 2 times by 1 test: 1;return 1; Executed by:
executed 2 times by 1 test: return 1; Executed by:
| 2 | ||||||||||||
306 | } | - | ||||||||||||
307 | - | |||||||||||||
308 | static int conn_read(BIO *b, char *out, int outl) | - | ||||||||||||
309 | { | - | ||||||||||||
310 | int ret = 0; | - | ||||||||||||
311 | BIO_CONNECT *data; | - | ||||||||||||
312 | - | |||||||||||||
313 | data = (BIO_CONNECT *)b->ptr; | - | ||||||||||||
314 | if (data->state != 5
| 0-6934 | ||||||||||||
315 | ret = conn_state(b, data); | - | ||||||||||||
316 | if (ret <= 0
| 0 | ||||||||||||
317 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||
318 | } never executed: end of block | 0 | ||||||||||||
319 | - | |||||||||||||
320 | if (out !=
| 0-6934 | ||||||||||||
321 | ((void *)0)
| 0-6934 | ||||||||||||
322 | ) { | - | ||||||||||||
323 | - | |||||||||||||
324 | (*__errno_location ()) | - | ||||||||||||
325 | =0; | - | ||||||||||||
326 | ret = read((b->num),(out),(outl)); | - | ||||||||||||
327 | BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08)); | - | ||||||||||||
328 | if (ret <= 0
| 36-6898 | ||||||||||||
329 | if (BIO_sock_should_retry(ret)
| 0-6898 | ||||||||||||
330 | BIO_set_flags(b, (0x01|0x08)); executed 6898 times by 1 test: BIO_set_flags(b, (0x01|0x08)); Executed by:
| 6898 | ||||||||||||
331 | } executed 6898 times by 1 test: end of block Executed by:
| 6898 | ||||||||||||
332 | } executed 6934 times by 1 test: end of block Executed by:
| 6934 | ||||||||||||
333 | return executed 6934 times by 1 test: ret;return ret; Executed by:
executed 6934 times by 1 test: return ret; Executed by:
| 6934 | ||||||||||||
334 | } | - | ||||||||||||
335 | - | |||||||||||||
336 | static int conn_write(BIO *b, const char *in, int inl) | - | ||||||||||||
337 | { | - | ||||||||||||
338 | int ret; | - | ||||||||||||
339 | BIO_CONNECT *data; | - | ||||||||||||
340 | - | |||||||||||||
341 | data = (BIO_CONNECT *)b->ptr; | - | ||||||||||||
342 | if (data->state != 5
| 0-8 | ||||||||||||
343 | ret = conn_state(b, data); | - | ||||||||||||
344 | if (ret <= 0
| 0 | ||||||||||||
345 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||
346 | } never executed: end of block | 0 | ||||||||||||
347 | - | |||||||||||||
348 | - | |||||||||||||
349 | (*__errno_location ()) | - | ||||||||||||
350 | =0; | - | ||||||||||||
351 | ret = write((b->num),(in),(inl)); | - | ||||||||||||
352 | BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08)); | - | ||||||||||||
353 | if (ret <= 0
| 0-8 | ||||||||||||
354 | if (BIO_sock_should_retry(ret)
| 0 | ||||||||||||
355 | BIO_set_flags(b, (0x02|0x08)); never executed: BIO_set_flags(b, (0x02|0x08)); | 0 | ||||||||||||
356 | } never executed: end of block | 0 | ||||||||||||
357 | return executed 8 times by 1 test: ret;return ret; Executed by:
executed 8 times by 1 test: return ret; Executed by:
| 8 | ||||||||||||
358 | } | - | ||||||||||||
359 | - | |||||||||||||
360 | static long conn_ctrl(BIO *b, int cmd, long num, void *ptr) | - | ||||||||||||
361 | { | - | ||||||||||||
362 | BIO *dbio; | - | ||||||||||||
363 | int *ip; | - | ||||||||||||
364 | const char **pptr = | - | ||||||||||||
365 | ((void *)0) | - | ||||||||||||
366 | ; | - | ||||||||||||
367 | long ret = 1; | - | ||||||||||||
368 | BIO_CONNECT *data; | - | ||||||||||||
369 | - | |||||||||||||
370 | data = (BIO_CONNECT *)b->ptr; | - | ||||||||||||
371 | - | |||||||||||||
372 | switch (cmd) { | - | ||||||||||||
373 | case never executed: 1:case 1: never executed: case 1: | 0 | ||||||||||||
374 | ret = 0; | - | ||||||||||||
375 | data->state = 1; | - | ||||||||||||
376 | conn_close_socket(b); | - | ||||||||||||
377 | BIO_ADDRINFO_free(data->addr_first); | - | ||||||||||||
378 | data->addr_first = | - | ||||||||||||
379 | ((void *)0) | - | ||||||||||||
380 | ; | - | ||||||||||||
381 | b->flags = 0; | - | ||||||||||||
382 | break; never executed: break; | 0 | ||||||||||||
383 | case executed 4 times by 1 test: 101:case 101: Executed by:
executed 4 times by 1 test: case 101: Executed by:
| 4 | ||||||||||||
384 | - | |||||||||||||
385 | if (data->state != 5
| 0-4 | ||||||||||||
386 | ret = (long)conn_state(b, data); executed 4 times by 1 test: ret = (long)conn_state(b, data); Executed by:
| 4 | ||||||||||||
387 | else | - | ||||||||||||
388 | ret = 1; never executed: ret = 1; | 0 | ||||||||||||
389 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||
390 | case never executed: 123:case 123: never executed: case 123: | 0 | ||||||||||||
391 | if (ptr !=
| 0 | ||||||||||||
392 | ((void *)0)
| 0 | ||||||||||||
393 | ) { | - | ||||||||||||
394 | pptr = (const char **)ptr; | - | ||||||||||||
395 | if (num == 0
| 0 | ||||||||||||
396 | *pptr = data->param_hostname; | - | ||||||||||||
397 | } never executed: else if (num == 1end of block
| 0 | ||||||||||||
398 | *pptr = data->param_service; | - | ||||||||||||
399 | } never executed: else if (num == 2end of block
| 0 | ||||||||||||
400 | *pptr = (const char *)BIO_ADDRINFO_address(data->addr_iter); | - | ||||||||||||
401 | } never executed: else if (num == 3end of block
| 0 | ||||||||||||
402 | switch (BIO_ADDRINFO_family(data->addr_iter)) { | - | ||||||||||||
403 | - | |||||||||||||
404 | case never executed: case 10 : never executed: case 10 : | 0 | ||||||||||||
405 | 10 never executed: case 10 : | 0 | ||||||||||||
406 | : never executed: case 10 : | 0 | ||||||||||||
407 | ret = 6; | - | ||||||||||||
408 | break; never executed: break; | 0 | ||||||||||||
409 | - | |||||||||||||
410 | case never executed: case 2 : never executed: case 2 : | 0 | ||||||||||||
411 | 2 never executed: case 2 : | 0 | ||||||||||||
412 | : never executed: case 2 : | 0 | ||||||||||||
413 | ret = 4; | - | ||||||||||||
414 | break; never executed: break; | 0 | ||||||||||||
415 | case never executed: 0:case 0: never executed: case 0: | 0 | ||||||||||||
416 | ret = data->connect_family; | - | ||||||||||||
417 | break; never executed: break; | 0 | ||||||||||||
418 | default never executed: :default: never executed: default: | 0 | ||||||||||||
419 | ret = -1; | - | ||||||||||||
420 | break; never executed: break; | 0 | ||||||||||||
421 | } | - | ||||||||||||
422 | } else { | - | ||||||||||||
423 | ret = 0; | - | ||||||||||||
424 | } never executed: end of block | 0 | ||||||||||||
425 | } else { | - | ||||||||||||
426 | ret = 0; | - | ||||||||||||
427 | } never executed: end of block | 0 | ||||||||||||
428 | break; never executed: break; | 0 | ||||||||||||
429 | case executed 4 times by 1 test: 100:case 100: Executed by:
executed 4 times by 1 test: case 100: Executed by:
| 4 | ||||||||||||
430 | if (ptr !=
| 0-4 | ||||||||||||
431 | ((void *)0)
| 0-4 | ||||||||||||
432 | ) { | - | ||||||||||||
433 | b->init = 1; | - | ||||||||||||
434 | if (num == 0
| 2 | ||||||||||||
435 | char *hold_service = data->param_service; | - | ||||||||||||
436 | - | |||||||||||||
437 | - | |||||||||||||
438 | - | |||||||||||||
439 | - | |||||||||||||
440 | CRYPTO_free(data->param_hostname, __FILE__, 407); | - | ||||||||||||
441 | data->param_hostname = | - | ||||||||||||
442 | ((void *)0) | - | ||||||||||||
443 | ; | - | ||||||||||||
444 | ret = BIO_parse_hostserv(ptr, | - | ||||||||||||
445 | &data->param_hostname, | - | ||||||||||||
446 | &data->param_service, | - | ||||||||||||
447 | BIO_PARSE_PRIO_HOST); | - | ||||||||||||
448 | if (hold_service != data->param_service
| 0-2 | ||||||||||||
449 | CRYPTO_free(hold_service, __FILE__, 414); executed 2 times by 1 test: CRYPTO_free(hold_service, __FILE__, 414); Executed by:
| 2 | ||||||||||||
450 | } executed 2 times by 1 test: else if (num == 1end of block Executed by:
| 0-2 | ||||||||||||
451 | CRYPTO_free(data->param_service, __FILE__, 416); | - | ||||||||||||
452 | data->param_service = CRYPTO_strdup(ptr, __FILE__, 417); | - | ||||||||||||
453 | } never executed: else if (num == 2end of block
| 0-2 | ||||||||||||
454 | const BIO_ADDR *addr = (const BIO_ADDR *)ptr; | - | ||||||||||||
455 | if (ret
| 0 | ||||||||||||
456 | data->param_hostname = BIO_ADDR_hostname_string(addr, 1); | - | ||||||||||||
457 | data->param_service = BIO_ADDR_service_string(addr, 1); | - | ||||||||||||
458 | BIO_ADDRINFO_free(data->addr_first); | - | ||||||||||||
459 | data->addr_first = | - | ||||||||||||
460 | ((void *)0) | - | ||||||||||||
461 | ; | - | ||||||||||||
462 | data->addr_iter = | - | ||||||||||||
463 | ((void *)0) | - | ||||||||||||
464 | ; | - | ||||||||||||
465 | } never executed: end of block | 0 | ||||||||||||
466 | } never executed: else if (num == 3end of block
| 0-2 | ||||||||||||
467 | data->connect_family = *(int *)ptr; | - | ||||||||||||
468 | } executed 2 times by 1 test: else {end of block Executed by:
| 2 | ||||||||||||
469 | ret = 0; | - | ||||||||||||
470 | } never executed: end of block | 0 | ||||||||||||
471 | } | - | ||||||||||||
472 | break; executed 4 times by 1 test: break; Executed by:
| 4 | ||||||||||||
473 | case executed 2 times by 1 test: 102:case 102: Executed by:
executed 2 times by 1 test: case 102: Executed by:
| 2 | ||||||||||||
474 | if (num != 0
| 0-2 | ||||||||||||
475 | data->connect_mode |= 0x08; executed 2 times by 1 test: data->connect_mode |= 0x08; Executed by:
| 2 | ||||||||||||
476 | else | - | ||||||||||||
477 | data->connect_mode &= ~0x08; never executed: data->connect_mode &= ~0x08; | 0 | ||||||||||||
478 | break; executed 2 times by 1 test: break; Executed by:
| 2 | ||||||||||||
479 | case never executed: 155:case 155: never executed: case 155: | 0 | ||||||||||||
480 | data->connect_mode = (int)num; | - | ||||||||||||
481 | break; never executed: break; | 0 | ||||||||||||
482 | case never executed: 105:case 105: never executed: case 105: | 0 | ||||||||||||
483 | if (b->init
| 0 | ||||||||||||
484 | ip = (int *)ptr; | - | ||||||||||||
485 | if (ip !=
| 0 | ||||||||||||
486 | ((void *)0)
| 0 | ||||||||||||
487 | ) | - | ||||||||||||
488 | * never executed: ip = b->num;*ip = b->num; never executed: *ip = b->num; | 0 | ||||||||||||
489 | ret = b->num; | - | ||||||||||||
490 | } never executed: elseend of block | 0 | ||||||||||||
491 | ret = -1; never executed: ret = -1; | 0 | ||||||||||||
492 | break; never executed: break; | 0 | ||||||||||||
493 | case never executed: 8:case 8: never executed: case 8: | 0 | ||||||||||||
494 | ret = b->shutdown; | - | ||||||||||||
495 | break; never executed: break; | 0 | ||||||||||||
496 | case never executed: 9:case 9: never executed: case 9: | 0 | ||||||||||||
497 | b->shutdown = (int)num; | - | ||||||||||||
498 | break; never executed: break; | 0 | ||||||||||||
499 | case never executed: 10:case 10: never executed: case 10: | 0 | ||||||||||||
500 | case never executed: 13:case 13: never executed: case 13: | 0 | ||||||||||||
501 | ret = 0; | - | ||||||||||||
502 | break; never executed: break; | 0 | ||||||||||||
503 | case executed 6 times by 1 test: 11:case 11: Executed by:
executed 6 times by 1 test: case 11: Executed by:
| 6 | ||||||||||||
504 | break; executed 6 times by 1 test: break; Executed by:
| 6 | ||||||||||||
505 | case never executed: 12:case 12: never executed: case 12: | 0 | ||||||||||||
506 | { | - | ||||||||||||
507 | dbio = (BIO *)ptr; | - | ||||||||||||
508 | if (data->param_hostname
| 0 | ||||||||||||
509 | BIO_ctrl(dbio,100,0, (char *)(data->param_hostname)); never executed: BIO_ctrl(dbio,100,0, (char *)(data->param_hostname)); | 0 | ||||||||||||
510 | if (data->param_service
| 0 | ||||||||||||
511 | BIO_ctrl(dbio,100,1, (char *)(data->param_service)); never executed: BIO_ctrl(dbio,100,1, (char *)(data->param_service)); | 0 | ||||||||||||
512 | BIO_int_ctrl(dbio,100,3,data->connect_family); | - | ||||||||||||
513 | BIO_ctrl(dbio,155,(data->connect_mode), | - | ||||||||||||
514 | ((void *)0) | - | ||||||||||||
515 | ); | - | ||||||||||||
516 | - | |||||||||||||
517 | - | |||||||||||||
518 | - | |||||||||||||
519 | - | |||||||||||||
520 | (void)(int)BIO_callback_ctrl(dbio,14,data->info_callback); | - | ||||||||||||
521 | } | - | ||||||||||||
522 | break; never executed: break; | 0 | ||||||||||||
523 | case never executed: 14:case 14: never executed: case 14: | 0 | ||||||||||||
524 | ret = 0; | - | ||||||||||||
525 | break; never executed: break; | 0 | ||||||||||||
526 | case never executed: 15:case 15: never executed: case 15: | 0 | ||||||||||||
527 | { | - | ||||||||||||
528 | BIO_info_cb **fptr; | - | ||||||||||||
529 | - | |||||||||||||
530 | fptr = (BIO_info_cb **)ptr; | - | ||||||||||||
531 | *fptr = data->info_callback; | - | ||||||||||||
532 | } | - | ||||||||||||
533 | break; never executed: break; | 0 | ||||||||||||
534 | default executed 12 times by 1 test: :default: Executed by:
executed 12 times by 1 test: default: Executed by:
| 12 | ||||||||||||
535 | ret = 0; | - | ||||||||||||
536 | break; executed 12 times by 1 test: break; Executed by:
| 12 | ||||||||||||
537 | } | - | ||||||||||||
538 | return executed 28 times by 1 test: ret;return ret; Executed by:
executed 28 times by 1 test: return ret; Executed by:
| 28 | ||||||||||||
539 | } | - | ||||||||||||
540 | - | |||||||||||||
541 | static long conn_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp) | - | ||||||||||||
542 | { | - | ||||||||||||
543 | long ret = 1; | - | ||||||||||||
544 | BIO_CONNECT *data; | - | ||||||||||||
545 | - | |||||||||||||
546 | data = (BIO_CONNECT *)b->ptr; | - | ||||||||||||
547 | - | |||||||||||||
548 | switch (cmd) { | - | ||||||||||||
549 | case never executed: 14:case 14: never executed: case 14: | 0 | ||||||||||||
550 | { | - | ||||||||||||
551 | data->info_callback = fp; | - | ||||||||||||
552 | } | - | ||||||||||||
553 | break; never executed: break; | 0 | ||||||||||||
554 | default never executed: :default: never executed: default: | 0 | ||||||||||||
555 | ret = 0; | - | ||||||||||||
556 | break; never executed: break; | 0 | ||||||||||||
557 | } | - | ||||||||||||
558 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||
559 | } | - | ||||||||||||
560 | - | |||||||||||||
561 | static int conn_puts(BIO *bp, const char *str) | - | ||||||||||||
562 | { | - | ||||||||||||
563 | int n, ret; | - | ||||||||||||
564 | - | |||||||||||||
565 | n = strlen(str); | - | ||||||||||||
566 | ret = conn_write(bp, str, n); | - | ||||||||||||
567 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||
568 | } | - | ||||||||||||
569 | - | |||||||||||||
570 | BIO *BIO_new_connect(const char *str) | - | ||||||||||||
571 | { | - | ||||||||||||
572 | BIO *ret; | - | ||||||||||||
573 | - | |||||||||||||
574 | ret = BIO_new(BIO_s_connect()); | - | ||||||||||||
575 | if (ret ==
| 0-2 | ||||||||||||
576 | ((void *)0)
| 0-2 | ||||||||||||
577 | ) | - | ||||||||||||
578 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||
579 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||
580 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||
581 | if (BIO_ctrl(ret,100,0, (char *)(str))
| 0-2 | ||||||||||||
582 | return executed 2 times by 1 test: ret;return ret; Executed by:
executed 2 times by 1 test: return ret; Executed by:
| 2 | ||||||||||||
583 | BIO_free(ret); | - | ||||||||||||
584 | return never executed: return ((void *)0) ; never executed: return ((void *)0) ; | 0 | ||||||||||||
585 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||
586 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||
587 | } | - | ||||||||||||
Switch to Source code | Preprocessed file |