OpenCoverage

bss_sock.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/bio/bss_sock.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4static int sock_write(BIO *h, const char *buf, int num);-
5static int sock_read(BIO *h, char *buf, int size);-
6static int sock_puts(BIO *h, const char *str);-
7static long sock_ctrl(BIO *h, int cmd, long arg1, void *arg2);-
8static int sock_new(BIO *h);-
9static int sock_free(BIO *data);-
10int BIO_sock_should_retry(int s);-
11-
12static const BIO_METHOD methods_sockp = {-
13 .type = (5|0x0400|0x0100),-
14 .name = "socket",-
15 .bwrite = sock_write,-
16 .bread = sock_read,-
17 .bputs = sock_puts,-
18 .ctrl = sock_ctrl,-
19 .create = sock_new,-
20 .destroy = sock_free-
21};-
22-
23const BIO_METHOD *-
24BIO_s_socket(void)-
25{-
26 return
executed 6 times by 1 test: return (&methods_sockp);
Executed by:
  • tlstest
(&methods_sockp);
executed 6 times by 1 test: return (&methods_sockp);
Executed by:
  • tlstest
6
27}-
28-
29BIO *-
30BIO_new_socket(int fd, int close_flag)-
31{-
32 BIO *ret;-
33-
34 ret = BIO_new(BIO_s_socket());-
35 if (ret ==
ret == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
36 ((void *)0)
ret == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
37 )-
38 return
never executed: return ( ((void *)0) );
(
never executed: return ( ((void *)0) );
0
39 ((void *)0)
never executed: return ( ((void *)0) );
0
40 );
never executed: return ( ((void *)0) );
0
41 BIO_int_ctrl(ret,104,close_flag,fd);-
42 return
never executed: return (ret);
(ret);
never executed: return (ret);
0
43}-
44-
45static int-
46sock_new(BIO *bi)-
47{-
48 bi->init = 0;-
49 bi->num = 0;-
50 bi->ptr = -
51 ((void *)0)-
52 ;-
53 bi->flags = 0;-
54 return
executed 6 times by 1 test: return (1);
Executed by:
  • tlstest
(1);
executed 6 times by 1 test: return (1);
Executed by:
  • tlstest
6
55}-
56-
57static int-
58sock_free(BIO *a)-
59{-
60 if (a ==
a == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tlstest
0-12
61 ((void *)0)
a == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tlstest
0-12
62 )-
63 return
never executed: return (0);
(0);
never executed: return (0);
0
64 if (a->shutdown
a->shutdownDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tlstest
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tlstest
) {
6
65 if (a->init
a->initDescription
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tlstest
) {
0-6
66 shutdown(a->num, -
67 SHUT_RDWR-
68 );-
69 close(a->num);-
70 }
never executed: end of block
0
71 a->init = 0;-
72 a->flags = 0;-
73 }
executed 6 times by 1 test: end of block
Executed by:
  • tlstest
6
74 return
executed 12 times by 1 test: return (1);
Executed by:
  • tlstest
(1);
executed 12 times by 1 test: return (1);
Executed by:
  • tlstest
12
75}-
76-
77static int-
78sock_read(BIO *b, char *out, int outl)-
79{-
80 int ret = 0;-
81-
82 if (out !=
out != ((void *)0)Description
TRUEevaluated 46 times by 1 test
Evaluated by:
  • tlstest
FALSEnever evaluated
0-46
83 ((void *)0)
out != ((void *)0)Description
TRUEevaluated 46 times by 1 test
Evaluated by:
  • tlstest
FALSEnever evaluated
0-46
84 ) {-
85 -
86 (*__errno_location ()) -
87 = 0;-
88 ret = read(b->num, out, outl);-
89 BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08));-
90 if (ret <= 0
ret <= 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tlstest
FALSEevaluated 40 times by 1 test
Evaluated by:
  • tlstest
) {
6-40
91 if (BIO_sock_should_retry(ret)
BIO_sock_should_retry(ret)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tlstest
FALSEnever evaluated
)
0-6
92 BIO_set_flags(b, (0x01|0x08));
executed 6 times by 1 test: BIO_set_flags(b, (0x01|0x08));
Executed by:
  • tlstest
6
93 }
executed 6 times by 1 test: end of block
Executed by:
  • tlstest
6
94 }
executed 46 times by 1 test: end of block
Executed by:
  • tlstest
46
95 return
executed 46 times by 1 test: return (ret);
Executed by:
  • tlstest
(ret);
executed 46 times by 1 test: return (ret);
Executed by:
  • tlstest
46
96}-
97-
98static int-
99sock_write(BIO *b, const char *in, int inl)-
100{-
101 int ret;-
102-
103 -
104(*__errno_location ()) -
105 = 0;-
106 ret = write(b->num, in, inl);-
107 BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08));-
108 if (ret <= 0
ret <= 0Description
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tlstest
) {
0-12
109 if (BIO_sock_should_retry(ret)
BIO_sock_should_retry(ret)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
110 BIO_set_flags(b, (0x02|0x08));
never executed: BIO_set_flags(b, (0x02|0x08));
0
111 }
never executed: end of block
0
112 return
executed 12 times by 1 test: return (ret);
Executed by:
  • tlstest
(ret);
executed 12 times by 1 test: return (ret);
Executed by:
  • tlstest
12
113}-
114-
115static long-
116sock_ctrl(BIO *b, int cmd, long num, void *ptr)-
117{-
118 long ret = 1;-
119 int *ip;-
120-
121 switch (cmd) {-
122 case
executed 6 times by 1 test: case 104:
Executed by:
  • tlstest
104:
executed 6 times by 1 test: case 104:
Executed by:
  • tlstest
6
123 sock_free(b);-
124 b->num= *((int *)ptr);-
125 b->shutdown = (int)num;-
126 b->init = 1;-
127 break;
executed 6 times by 1 test: break;
Executed by:
  • tlstest
6
128 case
executed 4 times by 1 test: case 105:
Executed by:
  • tlstest
105:
executed 4 times by 1 test: case 105:
Executed by:
  • tlstest
4
129 if (b->init
b->initDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tlstest
FALSEnever evaluated
) {
0-4
130 ip = (int *)ptr;-
131 if (ip !=
ip != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tlstest
0-4
132 ((void *)0)
ip != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tlstest
0-4
133 )-
134 *
never executed: *ip = b->num;
ip = b->num;
never executed: *ip = b->num;
0
135 ret = b->num;-
136 }
executed 4 times by 1 test: end of block
Executed by:
  • tlstest
else
4
137 ret = -1;
never executed: ret = -1;
0
138 break;
executed 4 times by 1 test: break;
Executed by:
  • tlstest
4
139 case
never executed: case 8:
8:
never executed: case 8:
0
140 ret = b->shutdown;-
141 break;
never executed: break;
0
142 case
never executed: case 9:
9:
never executed: case 9:
0
143 b->shutdown = (int)num;-
144 break;
never executed: break;
0
145 case
never executed: case 12:
12:
never executed: case 12:
0
146 case
executed 6 times by 1 test: case 11:
Executed by:
  • tlstest
11:
executed 6 times by 1 test: case 11:
Executed by:
  • tlstest
6
147 ret = 1;-
148 break;
executed 6 times by 1 test: break;
Executed by:
  • tlstest
6
149 default
executed 8 times by 1 test: default:
Executed by:
  • tlstest
:
executed 8 times by 1 test: default:
Executed by:
  • tlstest
8
150 ret = 0;-
151 break;
executed 8 times by 1 test: break;
Executed by:
  • tlstest
8
152 }-
153 return
executed 24 times by 1 test: return (ret);
Executed by:
  • tlstest
(ret);
executed 24 times by 1 test: return (ret);
Executed by:
  • tlstest
24
154}-
155-
156static int-
157sock_puts(BIO *bp, const char *str)-
158{-
159 int n, ret;-
160-
161 n = strlen(str);-
162 ret = sock_write(bp, str, n);-
163 return
never executed: return (ret);
(ret);
never executed: return (ret);
0
164}-
165-
166int-
167BIO_sock_should_retry(int i)-
168{-
169 int err;-
170-
171 if ((
(i == 0)Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tlstest
i == 0)
(i == 0)Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tlstest
|| (
(i == -1)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tlstest
FALSEnever evaluated
i == -1)
(i == -1)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tlstest
FALSEnever evaluated
) {
0-6
172 err = -
173 (*__errno_location ())-
174 ;-
175 return
executed 6 times by 1 test: return (BIO_sock_non_fatal_error(err));
Executed by:
  • tlstest
(BIO_sock_non_fatal_error(err));
executed 6 times by 1 test: return (BIO_sock_non_fatal_error(err));
Executed by:
  • tlstest
6
176 }-
177 return
never executed: return (0);
(0);
never executed: return (0);
0
178}-
179-
180int-
181BIO_sock_non_fatal_error(int err)-
182{-
183 switch (err) {-
184 case
never executed: case 107 :
never executed: case 107 :
0
185 107
never executed: case 107 :
0
186 :
never executed: case 107 :
0
187 case
never executed: case 4 :
never executed: case 4 :
0
188 4
never executed: case 4 :
0
189 :
never executed: case 4 :
0
190 case
executed 6 times by 1 test: case 11 :
Executed by:
  • tlstest
executed 6 times by 1 test: case 11 :
Executed by:
  • tlstest
6
191 11
executed 6 times by 1 test: case 11 :
Executed by:
  • tlstest
6
192 :
executed 6 times by 1 test: case 11 :
Executed by:
  • tlstest
6
193 case
never executed: case 115 :
never executed: case 115 :
0
194 115
never executed: case 115 :
0
195 :
never executed: case 115 :
0
196 case
never executed: case 114 :
never executed: case 114 :
0
197 114
never executed: case 114 :
0
198 :
never executed: case 114 :
0
199 return
executed 6 times by 1 test: return (1);
Executed by:
  • tlstest
(1);
executed 6 times by 1 test: return (1);
Executed by:
  • tlstest
6
200 default
never executed: default:
:
never executed: default:
0
201 break;
never executed: break;
0
202 }-
203 return
never executed: return (0);
(0);
never executed: return (0);
0
204}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2