OpenCoverage

bss_sock.c

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

Generated by Squish Coco 4.2.2