OpenCoverage

bio_b64.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/evp/bio_b64.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3static int b64_write(BIO *h, const char *buf, int num);-
4static int b64_read(BIO *h, char *buf, int size);-
5static int b64_puts(BIO *h, const char *str);-
6-
7static long b64_ctrl(BIO *h, int cmd, long arg1, void *arg2);-
8static int b64_new(BIO *h);-
9static int b64_free(BIO *data);-
10static long b64_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp);-
11-
12-
13-
14-
15-
16-
17typedef struct b64_struct {-
18-
19 int buf_len;-
20 int buf_off;-
21 int tmp_len;-
22 int tmp_nl;-
23 int encode;-
24 int start;-
25 int cont;-
26 EVP_ENCODE_CTX base64;-
27 char buf[(((1024 +2)/3*4)+(1024/48+1)*2+80) + 10];-
28 char tmp[1024];-
29} BIO_B64_CTX;-
30-
31static const BIO_METHOD methods_b64 = {-
32 .type = (11|0x0200),-
33 .name = "base64 encoding",-
34 .bwrite = b64_write,-
35 .bread = b64_read,-
36 .bputs = b64_puts,-
37 .ctrl = b64_ctrl,-
38 .create = b64_new,-
39 .destroy = b64_free,-
40 .callback_ctrl = b64_callback_ctrl-
41};-
42-
43const BIO_METHOD *-
44BIO_f_base64(void)-
45{-
46 return
executed 253 times by 2 tests: return (&methods_b64);
Executed by:
  • base64test
  • libcrypto.so.44.0.1
(&methods_b64);
executed 253 times by 2 tests: return (&methods_b64);
Executed by:
  • base64test
  • libcrypto.so.44.0.1
253
47}-
48-
49static int-
50b64_new(BIO *bi)-
51{-
52 BIO_B64_CTX *ctx;-
53-
54 ctx = malloc(sizeof(BIO_B64_CTX));-
55 if (ctx ==
ctx == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 253 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
0-253
56 ((void *)0)
ctx == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 253 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
0-253
57 )-
58 return
never executed: return (0);
(0);
never executed: return (0);
0
59-
60 ctx->buf_len = 0;-
61 ctx->tmp_len = 0;-
62 ctx->tmp_nl = 0;-
63 ctx->buf_off = 0;-
64 ctx->cont = 1;-
65 ctx->start = 1;-
66 ctx->encode = 0;-
67-
68 bi->init = 1;-
69 bi->ptr = (char *)ctx;-
70 bi->flags = 0;-
71 bi->num = 0;-
72 return
executed 253 times by 2 tests: return (1);
Executed by:
  • base64test
  • libcrypto.so.44.0.1
(1);
executed 253 times by 2 tests: return (1);
Executed by:
  • base64test
  • libcrypto.so.44.0.1
253
73}-
74-
75static int-
76b64_free(BIO *a)-
77{-
78 if (a ==
a == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 253 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
0-253
79 ((void *)0)
a == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 253 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
0-253
80 )-
81 return
never executed: return (0);
(0);
never executed: return (0);
0
82 free(a->ptr);-
83 a->ptr = -
84 ((void *)0)-
85 ;-
86 a->init = 0;-
87 a->flags = 0;-
88 return
executed 253 times by 2 tests: return (1);
Executed by:
  • base64test
  • libcrypto.so.44.0.1
(1);
executed 253 times by 2 tests: return (1);
Executed by:
  • base64test
  • libcrypto.so.44.0.1
253
89}-
90-
91static int-
92b64_read(BIO *b, char *out, int outl)-
93{-
94 int ret = 0, i, ii, j, k, x, n, num, ret_code = 0;-
95 BIO_B64_CTX *ctx;-
96 unsigned char *p, *q;-
97-
98 if (out ==
out == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 298 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
0-298
99 ((void *)0)
out == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 298 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
0-298
100 )-
101 return
never executed: return (0);
(0);
never executed: return (0);
0
102 ctx = (BIO_B64_CTX *)b->ptr;-
103-
104 if ((
(ctx == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 298 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
ctx ==
(ctx == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 298 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
0-298
105 ((void *)0)
(ctx == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 298 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
0-298
106 )
(ctx == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 298 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
|| (
(b->next_bio == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 298 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
b->next_bio ==
(b->next_bio == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 298 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
0-298
107 ((void *)0)
(b->next_bio == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 298 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
0-298
108 )
(b->next_bio == ((void *)0) )Description
TRUEnever evaluated
FALSEevaluated 298 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
)
0-298
109 return
never executed: return (0);
(0);
never executed: return (0);
0
110-
111 BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08));-
112-
113 if (ctx->encode != 2
ctx->encode != 2Description
TRUEevaluated 150 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEevaluated 148 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
) {
148-150
114 ctx->encode = 2;-
115 ctx->buf_len = 0;-
116 ctx->buf_off = 0;-
117 ctx->tmp_len = 0;-
118 EVP_DecodeInit(&(ctx->base64));-
119 }
executed 150 times by 2 tests: end of block
Executed by:
  • base64test
  • libcrypto.so.44.0.1
150
120-
121-
122 if (ctx->buf_len > 0
ctx->buf_len > 0Description
TRUEevaluated 98 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEevaluated 200 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
) {
98-200
123 (void)((ctx->buf_len >= ctx->buf_off) ? 0 : (OpenSSLDie(__FILE__, 174, "ctx->buf_len >= ctx->buf_off"),1));-
124 i = ctx->buf_len - ctx->buf_off;-
125 if (i > outl
i > outlDescription
TRUEevaluated 49 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEevaluated 49 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
)
49
126 i = outl;
executed 49 times by 1 test: i = outl;
Executed by:
  • libcrypto.so.44.0.1
49
127 (void)((ctx->buf_off + i < (int)sizeof(ctx->buf)) ? 0 : (OpenSSLDie(__FILE__, 178, "ctx->buf_off + i < (int)sizeof(ctx->buf)"),1));-
128 memcpy(out, &(ctx->buf[ctx->buf_off]), i);-
129 ret = i;-
130 out += i;-
131 outl -= i;-
132 ctx->buf_off += i;-
133 if (ctx->buf_len == ctx->buf_off
ctx->buf_len == ctx->buf_offDescription
TRUEevaluated 49 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEevaluated 49 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
) {
49
134 ctx->buf_len = 0;-
135 ctx->buf_off = 0;-
136 }
executed 49 times by 1 test: end of block
Executed by:
  • libcrypto.so.44.0.1
49
137 }
executed 98 times by 1 test: end of block
Executed by:
  • libcrypto.so.44.0.1
98
138-
139-
140-
141-
142 ret_code = 0;-
143 while (outl > 0
outl > 0Description
TRUEevaluated 464 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEevaluated 98 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
) {
98-464
144 if (ctx->cont <= 0
ctx->cont <= 0Description
TRUEevaluated 124 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEevaluated 340 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
)
124-340
145 break;
executed 124 times by 2 tests: break;
Executed by:
  • base64test
  • libcrypto.so.44.0.1
124
146-
147 i = BIO_read(b->next_bio, &(ctx->tmp[ctx->tmp_len]),-
148 1024 - ctx->tmp_len);-
149-
150 if (i <= 0
i <= 0Description
TRUEevaluated 142 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEevaluated 198 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
) {
142-198
151 ret_code = i;-
152-
153-
154 if (!BIO_test_flags(b->next_bio, 0x08)
!BIO_test_flag...ext_bio, 0x08)Description
TRUEevaluated 142 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEnever evaluated
) {
0-142
155 ctx->cont = i;-
156-
157 if (ctx->tmp_len == 0
ctx->tmp_len == 0Description
TRUEevaluated 68 times by 1 test
Evaluated by:
  • base64test
FALSEevaluated 74 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
)
68-74
158 break;
executed 68 times by 1 test: break;
Executed by:
  • base64test
68
159-
160 else-
161 i = 0;
executed 74 times by 2 tests: i = 0;
Executed by:
  • base64test
  • libcrypto.so.44.0.1
74
162 }-
163-
164 else-
165 break;
never executed: break;
0
166 }-
167 i += ctx->tmp_len;-
168 ctx->tmp_len = i;-
169-
170-
171-
172 if (ctx->start
ctx->startDescription
TRUEevaluated 172 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEevaluated 100 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
&& (
(BIO_test_flag...0x0)) & 0x100)Description
TRUEevaluated 60 times by 1 test
Evaluated by:
  • base64test
FALSEevaluated 112 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
BIO_test_flags(b, ~(0x0)) & 0x100)
(BIO_test_flag...0x0)) & 0x100)Description
TRUEevaluated 60 times by 1 test
Evaluated by:
  • base64test
FALSEevaluated 112 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
) {
60-172
173-
174 ctx->tmp_len = 0;-
175 }
executed 60 times by 1 test: end of block
Executed by:
  • base64test
else if (ctx->start
ctx->startDescription
TRUEevaluated 112 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEevaluated 100 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
) {
60-112
176 q = p =(unsigned char *)ctx->tmp;-
177 num = 0;-
178 for (j = 0; j < i
j < iDescription
TRUEevaluated 3890 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEevaluated 24 times by 1 test
Evaluated by:
  • base64test
; j++) {
24-3890
179 if (*(
*(q++) != '\n'Description
TRUEevaluated 3778 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEevaluated 112 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
q++) != '\n'
*(q++) != '\n'Description
TRUEevaluated 3778 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEevaluated 112 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
)
112-3778
180 continue;
executed 3778 times by 2 tests: continue;
Executed by:
  • base64test
  • libcrypto.so.44.0.1
3778
181-
182-
183-
184-
185-
186 if (ctx->tmp_nl
ctx->tmp_nlDescription
TRUEnever evaluated
FALSEevaluated 112 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
) {
0-112
187 p = q;-
188 ctx->tmp_nl = 0;-
189 continue;
never executed: continue;
0
190 }-
191-
192 k = EVP_DecodeUpdate(&(ctx->base64),-
193 (unsigned char *)ctx->buf,-
194 &num, p, q - p);-
195 if ((
(k <= 0)Description
TRUEevaluated 43 times by 1 test
Evaluated by:
  • base64test
FALSEevaluated 69 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
k <= 0)
(k <= 0)Description
TRUEevaluated 43 times by 1 test
Evaluated by:
  • base64test
FALSEevaluated 69 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
&& (
(num == 0)Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • base64test
FALSEevaluated 19 times by 1 test
Evaluated by:
  • base64test
num == 0)
(num == 0)Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • base64test
FALSEevaluated 19 times by 1 test
Evaluated by:
  • base64test
&& (
(ctx->start)Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • base64test
FALSEnever evaluated
ctx->start)
(ctx->start)Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • base64test
FALSEnever evaluated
)
0-69
196 EVP_DecodeInit(&ctx->base64);
executed 24 times by 1 test: EVP_DecodeInit(&ctx->base64);
Executed by:
  • base64test
24
197 else {-
198 if (p != (unsigned char *)
p != (unsigned...&(ctx->tmp[0])Description
TRUEnever evaluated
FALSEevaluated 88 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
0-88
199 &(ctx->tmp[0])
p != (unsigned...&(ctx->tmp[0])Description
TRUEnever evaluated
FALSEevaluated 88 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
) {
0-88
200 i -= (p - (unsigned char *)-
201 &(ctx->tmp[0]));-
202 for (x = 0; x < i
x < iDescription
TRUEnever evaluated
FALSEnever evaluated
; x++)
0
203 ctx->tmp[x] = p[x];
never executed: ctx->tmp[x] = p[x];
0
204 }
never executed: end of block
0
205 EVP_DecodeInit(&ctx->base64);-
206 ctx->start = 0;-
207 break;
executed 88 times by 2 tests: break;
Executed by:
  • base64test
  • libcrypto.so.44.0.1
88
208 }-
209 p = q;-
210 }
executed 24 times by 1 test: end of block
Executed by:
  • base64test
24
211-
212-
213 if ((
(j == i)Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • base64test
FALSEevaluated 88 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
j == i)
(j == i)Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • base64test
FALSEevaluated 88 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
&& (
(num == 0)Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • base64test
FALSEnever evaluated
num == 0)
(num == 0)Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • base64test
FALSEnever evaluated
) {
0-88
214-
215-
216 if (p == (unsigned char *)&(ctx->tmp[0])
p == (unsigned...&(ctx->tmp[0])Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • base64test
) {
0-24
217-
218 if (i == 1024
i == 1024Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
219 ctx->tmp_nl = 1;-
220 ctx->tmp_len = 0;-
221 }
never executed: end of block
0
222 }
never executed: end of block
0
223 else if (p != q
p != qDescription
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • base64test
)
0-24
224 {-
225 n = q - p;-
226 for (ii = 0; ii < n
ii < nDescription
TRUEnever evaluated
FALSEnever evaluated
; ii++)
0
227 ctx->tmp[ii] = p[ii];
never executed: ctx->tmp[ii] = p[ii];
0
228 ctx->tmp_len = n;-
229 }
never executed: end of block
0
230-
231 continue;
executed 24 times by 1 test: continue;
Executed by:
  • base64test
24
232 } else {-
233 ctx->tmp_len = 0;-
234 }
executed 88 times by 2 tests: end of block
Executed by:
  • base64test
  • libcrypto.so.44.0.1
88
235 } else if ((
(i < 1024)Description
TRUEevaluated 100 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
i < 1024)
(i < 1024)Description
TRUEevaluated 100 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEnever evaluated
&& (
(ctx->cont > 0)Description
TRUEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
ctx->cont > 0)
(ctx->cont > 0)Description
TRUEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
FALSEevaluated 50 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
) {
0-100
236-
237-
238-
239 continue;
executed 50 times by 1 test: continue;
Executed by:
  • libcrypto.so.44.0.1
50
240 }-
241-
242 if (BIO_test_flags(b, ~(0x0)) & 0x100
BIO_test_flags...(0x0)) & 0x100Description
TRUEevaluated 60 times by 1 test
Evaluated by:
  • base64test
FALSEevaluated 138 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
) {
60-138
243 int z, jj;-
244-
245 jj = i & ~3;-
246 z = EVP_DecodeBlock((unsigned char *)ctx->buf,-
247 (unsigned char *)ctx->tmp, jj);-
248 if (jj > 2
jj > 2Description
TRUEevaluated 45 times by 1 test
Evaluated by:
  • base64test
FALSEevaluated 15 times by 1 test
Evaluated by:
  • base64test
) {
15-45
249 if (ctx->tmp[jj-1] == '='
ctx->tmp[jj-1] == '='Description
TRUEevaluated 27 times by 1 test
Evaluated by:
  • base64test
FALSEevaluated 18 times by 1 test
Evaluated by:
  • base64test
) {
18-27
250 z--;-
251 if (ctx->tmp[jj-2] == '='
ctx->tmp[jj-2] == '='Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • base64test
FALSEevaluated 10 times by 1 test
Evaluated by:
  • base64test
)
10-17
252 z--;
executed 17 times by 1 test: z--;
Executed by:
  • base64test
17
253 }
executed 27 times by 1 test: end of block
Executed by:
  • base64test
27
254 }
executed 45 times by 1 test: end of block
Executed by:
  • base64test
45
255-
256-
257 if (jj != i
jj != iDescription
TRUEevaluated 30 times by 1 test
Evaluated by:
  • base64test
FALSEevaluated 30 times by 1 test
Evaluated by:
  • base64test
) {
30
258 memmove(ctx->tmp, &ctx->tmp[jj], i - jj);-
259 ctx->tmp_len = i - jj;-
260 }
executed 30 times by 1 test: end of block
Executed by:
  • base64test
30
261 ctx->buf_len = 0;-
262 if (z > 0
z > 0Description
TRUEevaluated 37 times by 1 test
Evaluated by:
  • base64test
FALSEevaluated 23 times by 1 test
Evaluated by:
  • base64test
) {
23-37
263 ctx->buf_len = z;-
264 }
executed 37 times by 1 test: end of block
Executed by:
  • base64test
37
265 i = z;-
266 }
executed 60 times by 1 test: end of block
Executed by:
  • base64test
else {
60
267 i = EVP_DecodeUpdate(&(ctx->base64),-
268 (unsigned char *)ctx->buf, &ctx->buf_len,-
269 (unsigned char *)ctx->tmp, i);-
270 ctx->tmp_len = 0;-
271 }
executed 138 times by 2 tests: end of block
Executed by:
  • base64test
  • libcrypto.so.44.0.1
138
272 ctx->buf_off = 0;-
273 if (i < 0
i < 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • base64test
FALSEevaluated 190 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
) {
8-190
274 ret_code = 0;-
275 ctx->buf_len = 0;-
276 break;
executed 8 times by 1 test: break;
Executed by:
  • base64test
8
277 }-
278-
279 if (ctx->buf_len <= outl
ctx->buf_len <= outlDescription
TRUEevaluated 141 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEevaluated 49 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
)
49-141
280 i = ctx->buf_len;
executed 141 times by 2 tests: i = ctx->buf_len;
Executed by:
  • base64test
  • libcrypto.so.44.0.1
141
281 else-
282 i = outl;
executed 49 times by 1 test: i = outl;
Executed by:
  • libcrypto.so.44.0.1
49
283-
284 memcpy(out, ctx->buf, i);-
285 ret += i;-
286 ctx->buf_off = i;-
287 if (ctx->buf_off == ctx->buf_len
ctx->buf_off == ctx->buf_lenDescription
TRUEevaluated 141 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEevaluated 49 times by 1 test
Evaluated by:
  • libcrypto.so.44.0.1
) {
49-141
288 ctx->buf_len = 0;-
289 ctx->buf_off = 0;-
290 }
executed 141 times by 2 tests: end of block
Executed by:
  • base64test
  • libcrypto.so.44.0.1
141
291 outl -= i;-
292 out += i;-
293 }
executed 190 times by 2 tests: end of block
Executed by:
  • base64test
  • libcrypto.so.44.0.1
190
294-
295 BIO_copy_next_retry(b);-
296 return
executed 298 times by 2 tests: return ((ret == 0) ? ret_code : ret);
Executed by:
  • base64test
  • libcrypto.so.44.0.1
((
(ret == 0)Description
TRUEevaluated 81 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEevaluated 217 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
ret == 0)
(ret == 0)Description
TRUEevaluated 81 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEevaluated 217 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
? ret_code : ret);
executed 298 times by 2 tests: return ((ret == 0) ? ret_code : ret);
Executed by:
  • base64test
  • libcrypto.so.44.0.1
81-298
297}-
298-
299static int-
300b64_write(BIO *b, const char *in, int inl)-
301{-
302 int ret = 0;-
303 int n;-
304 int i;-
305 BIO_B64_CTX *ctx;-
306-
307 ctx = (BIO_B64_CTX *)b->ptr;-
308 BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08));-
309-
310 if (ctx->encode != 1
ctx->encode != 1Description
TRUEevaluated 103 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEevaluated 194 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
) {
103-194
311 ctx->encode = 1;-
312 ctx->buf_len = 0;-
313 ctx->buf_off = 0;-
314 ctx->tmp_len = 0;-
315 EVP_EncodeInit(&(ctx->base64));-
316 }
executed 103 times by 2 tests: end of block
Executed by:
  • base64test
  • libcrypto.so.44.0.1
103
317-
318 (void)((ctx->buf_off < (int)sizeof(ctx->buf)) ? 0 : (OpenSSLDie(__FILE__, 369, "ctx->buf_off < (int)sizeof(ctx->buf)"),1));-
319 (void)((ctx->buf_len <= (int)sizeof(ctx->buf)) ? 0 : (OpenSSLDie(__FILE__, 370, "ctx->buf_len <= (int)sizeof(ctx->buf)"),1));-
320 (void)((ctx->buf_len >= ctx->buf_off) ? 0 : (OpenSSLDie(__FILE__, 371, "ctx->buf_len >= ctx->buf_off"),1));-
321 n = ctx->buf_len - ctx->buf_off;-
322 while (n > 0
n > 0Description
TRUEevaluated 74 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEevaluated 297 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
) {
74-297
323 i = BIO_write(b->next_bio, &(ctx->buf[ctx->buf_off]), n);-
324 if (i <= 0
i <= 0Description
TRUEnever evaluated
FALSEevaluated 74 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
) {
0-74
325 BIO_copy_next_retry(b);-
326 return
never executed: return (i);
(i);
never executed: return (i);
0
327 }-
328 (void)((i <= n) ? 0 : (OpenSSLDie(__FILE__, 379, "i <= n"),1));-
329 ctx->buf_off += i;-
330 (void)((ctx->buf_off <= (int)sizeof(ctx->buf)) ? 0 : (OpenSSLDie(__FILE__, 381, "ctx->buf_off <= (int)sizeof(ctx->buf)"),1));-
331 (void)((ctx->buf_len >= ctx->buf_off) ? 0 : (OpenSSLDie(__FILE__, 382, "ctx->buf_len >= ctx->buf_off"),1));-
332 n -= i;-
333 }
executed 74 times by 2 tests: end of block
Executed by:
  • base64test
  • libcrypto.so.44.0.1
74
334-
335 ctx->buf_off = 0;-
336 ctx->buf_len = 0;-
337-
338 if ((
(in == ((void *)0) )Description
TRUEevaluated 74 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEevaluated 223 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
in ==
(in == ((void *)0) )Description
TRUEevaluated 74 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEevaluated 223 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
74-223
339 ((void *)0)
(in == ((void *)0) )Description
TRUEevaluated 74 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEevaluated 223 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
74-223
340 )
(in == ((void *)0) )Description
TRUEevaluated 74 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEevaluated 223 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
|| (
(inl <= 0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • base64test
FALSEevaluated 221 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
inl <= 0)
(inl <= 0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • base64test
FALSEevaluated 221 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
)
2-223
341 return
executed 76 times by 2 tests: return (0);
Executed by:
  • base64test
  • libcrypto.so.44.0.1
(0);
executed 76 times by 2 tests: return (0);
Executed by:
  • base64test
  • libcrypto.so.44.0.1
76
342-
343 while (inl > 0
inl > 0Description
TRUEevaluated 235 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEevaluated 204 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
) {
204-235
344 n = (
(inl > 1024)Description
TRUEnever evaluated
FALSEevaluated 235 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
inl > 1024)
(inl > 1024)Description
TRUEnever evaluated
FALSEevaluated 235 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
? 1024 : inl;
0-235
345-
346 if (BIO_test_flags(b, ~(0x0)) & 0x100
BIO_test_flags...(0x0)) & 0x100Description
TRUEevaluated 36 times by 1 test
Evaluated by:
  • base64test
FALSEevaluated 199 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
) {
36-199
347 if (ctx->tmp_len > 0
ctx->tmp_len > 0Description
TRUEnever evaluated
FALSEevaluated 36 times by 1 test
Evaluated by:
  • base64test
) {
0-36
348 (void)((ctx->tmp_len <= 3) ? 0 : (OpenSSLDie(__FILE__, 397, "ctx->tmp_len <= 3"),1));-
349 n = 3 - ctx->tmp_len;-
350-
351 if (n > inl
n > inlDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
352 n = inl;
never executed: n = inl;
0
353 memcpy(&(ctx->tmp[ctx->tmp_len]), in, n);-
354 ctx->tmp_len += n;-
355 ret += n;-
356 if (ctx->tmp_len < 3
ctx->tmp_len < 3Description
TRUEnever evaluated
FALSEnever evaluated
)
0
357 break;
never executed: break;
0
358 ctx->buf_len = EVP_EncodeBlock(-
359 (unsigned char *)ctx->buf,-
360 (unsigned char *)ctx->tmp, ctx->tmp_len);-
361 (void)((ctx->buf_len <= (int)sizeof(ctx->buf)) ? 0 : (OpenSSLDie(-
362 __FILE__-
363 ,-
364 411-
365 , "ctx->buf_len <= (int)sizeof(ctx->buf)"),1))-
366 ;-
367 (void)((ctx->buf_len >= ctx->buf_off) ? 0 : (OpenSSLDie(__FILE__, 412, "ctx->buf_len >= ctx->buf_off"),1));-
368-
369-
370 ctx->tmp_len = 0;-
371 }
never executed: end of block
else {
0
372 if (n < 3
n < 3Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • base64test
FALSEevaluated 19 times by 1 test
Evaluated by:
  • base64test
) {
17-19
373 memcpy(ctx->tmp, in, n);-
374 ctx->tmp_len = n;-
375 ret += n;-
376 break;
executed 17 times by 1 test: break;
Executed by:
  • base64test
17
377 }-
378 n -= n % 3;-
379 ctx->buf_len = EVP_EncodeBlock(-
380 (unsigned char *)ctx->buf,-
381 (const unsigned char *)in, n);-
382 (void)((ctx->buf_len <= (int)sizeof(ctx->buf)) ? 0 : (OpenSSLDie(-
383 __FILE__-
384 ,-
385 428-
386 , "ctx->buf_len <= (int)sizeof(ctx->buf)"),1))-
387 ;-
388 (void)((ctx->buf_len >= ctx->buf_off) ? 0 : (OpenSSLDie(__FILE__, 429, "ctx->buf_len >= ctx->buf_off"),1));-
389 ret += n;-
390 }
executed 19 times by 1 test: end of block
Executed by:
  • base64test
19
391 } else {-
392 if (!EVP_EncodeUpdate(&(ctx->base64),
!EVP_EncodeUpd... char *)in, n)Description
TRUEnever evaluated
FALSEevaluated 199 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
0-199
393 (unsigned char *)ctx->buf, &ctx->buf_len,
!EVP_EncodeUpd... char *)in, n)Description
TRUEnever evaluated
FALSEevaluated 199 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
0-199
394 (unsigned char *)in, n)
!EVP_EncodeUpd... char *)in, n)Description
TRUEnever evaluated
FALSEevaluated 199 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
)
0-199
395 return
never executed: return ((ret == 0) ? -1 : ret);
((
(ret == 0)Description
TRUEnever evaluated
FALSEnever evaluated
ret == 0)
(ret == 0)Description
TRUEnever evaluated
FALSEnever evaluated
? -1 : ret);
never executed: return ((ret == 0) ? -1 : ret);
0
396 (void)((ctx->buf_len <= (int)sizeof(ctx->buf)) ? 0 : (OpenSSLDie(__FILE__, 437, "ctx->buf_len <= (int)sizeof(ctx->buf)"),1));-
397 (void)((ctx->buf_len >= ctx->buf_off) ? 0 : (OpenSSLDie(__FILE__, 438, "ctx->buf_len >= ctx->buf_off"),1));-
398 ret += n;-
399 }
executed 199 times by 2 tests: end of block
Executed by:
  • base64test
  • libcrypto.so.44.0.1
199
400 inl -= n;-
401 in += n;-
402-
403 ctx->buf_off = 0;-
404 n = ctx->buf_len;-
405 while (n > 0
n > 0Description
TRUEevaluated 91 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEevaluated 218 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
) {
91-218
406 i = BIO_write(b->next_bio, &(ctx->buf[ctx->buf_off]), n);-
407 if (i <= 0
i <= 0Description
TRUEnever evaluated
FALSEevaluated 91 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
) {
0-91
408 BIO_copy_next_retry(b);-
409 return
never executed: return ((ret == 0) ? i : ret);
((
(ret == 0)Description
TRUEnever evaluated
FALSEnever evaluated
ret == 0)
(ret == 0)Description
TRUEnever evaluated
FALSEnever evaluated
? i : ret);
never executed: return ((ret == 0) ? i : ret);
0
410 }-
411 (void)((i <= n) ? 0 : (OpenSSLDie(__FILE__, 452, "i <= n"),1));-
412 n -= i;-
413 ctx->buf_off += i;-
414 (void)((ctx->buf_off <= (int)sizeof(ctx->buf)) ? 0 : (OpenSSLDie(__FILE__, 455, "ctx->buf_off <= (int)sizeof(ctx->buf)"),1));-
415 (void)((ctx->buf_len >= ctx->buf_off) ? 0 : (OpenSSLDie(__FILE__, 456, "ctx->buf_len >= ctx->buf_off"),1));-
416 }
executed 91 times by 2 tests: end of block
Executed by:
  • base64test
  • libcrypto.so.44.0.1
91
417 ctx->buf_len = 0;-
418 ctx->buf_off = 0;-
419 }
executed 218 times by 2 tests: end of block
Executed by:
  • base64test
  • libcrypto.so.44.0.1
218
420 return
executed 221 times by 2 tests: return (ret);
Executed by:
  • base64test
  • libcrypto.so.44.0.1
(ret);
executed 221 times by 2 tests: return (ret);
Executed by:
  • base64test
  • libcrypto.so.44.0.1
221
421}-
422-
423static long-
424b64_ctrl(BIO *b, int cmd, long num, void *ptr)-
425{-
426 BIO_B64_CTX *ctx;-
427 long ret = 1;-
428 int i;-
429-
430 ctx = (BIO_B64_CTX *)b->ptr;-
431-
432 switch (cmd) {-
433 case
never executed: case 1:
1:
never executed: case 1:
0
434 ctx->cont = 1;-
435 ctx->start = 1;-
436 ctx->encode = 0;-
437 ret = BIO_ctrl(b->next_bio, cmd, num, ptr);-
438 break;
never executed: break;
0
439 case
never executed: case 2:
2:
never executed: case 2:
0
440 if (ctx->cont <= 0
ctx->cont <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
441 ret = 1;
never executed: ret = 1;
0
442 else-
443 ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
never executed: ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
0
444 break;
never executed: break;
0
445 case
never executed: case 13:
13:
never executed: case 13:
0
446 (void)((ctx->buf_len >= ctx->buf_off) ? 0 : (OpenSSLDie(__FILE__, 487, "ctx->buf_len >= ctx->buf_off"),1));-
447 ret = ctx->buf_len - ctx->buf_off;-
448 if ((
(ret == 0)Description
TRUEnever evaluated
FALSEnever evaluated
ret == 0)
(ret == 0)Description
TRUEnever evaluated
FALSEnever evaluated
&& (
(ctx->encode != 0)Description
TRUEnever evaluated
FALSEnever evaluated
ctx->encode != 0)
(ctx->encode != 0)Description
TRUEnever evaluated
FALSEnever evaluated
&&
0
449 (
(ctx->base64.num != 0)Description
TRUEnever evaluated
FALSEnever evaluated
ctx->base64.num != 0)
(ctx->base64.num != 0)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
450 ret = 1;
never executed: ret = 1;
0
451 else if (ret <= 0
ret <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
452 ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
never executed: ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
0
453 break;
never executed: break;
0
454 case
never executed: case 10:
10:
never executed: case 10:
0
455 (void)((ctx->buf_len >= ctx->buf_off) ? 0 : (OpenSSLDie(__FILE__, 496, "ctx->buf_len >= ctx->buf_off"),1));-
456 ret = ctx->buf_len - ctx->buf_off;-
457 if (ret <= 0
ret <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
458 ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
never executed: ret = BIO_ctrl(b->next_bio, cmd, num, ptr);
0
459 break;
never executed: break;
0
460 case
executed 103 times by 2 tests: case 11:
Executed by:
  • base64test
  • libcrypto.so.44.0.1
11:
executed 103 times by 2 tests: case 11:
Executed by:
  • base64test
  • libcrypto.so.44.0.1
103
461-
462again:-
463 while (ctx->buf_len != ctx->buf_off
ctx->buf_len != ctx->buf_offDescription
TRUEevaluated 74 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEevaluated 177 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
) {
74-177
464 i = b64_write(b, -
465 ((void *)0)-
466 , 0);-
467 if (i < 0
i < 0Description
TRUEnever evaluated
FALSEevaluated 74 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
)
0-74
468 return
never executed: return i;
i;
never executed: return i;
0
469 }
executed 74 times by 2 tests: end of block
Executed by:
  • base64test
  • libcrypto.so.44.0.1
74
470 if (BIO_test_flags(b, ~(0x0)) & 0x100
BIO_test_flags...(0x0)) & 0x100Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • base64test
FALSEevaluated 137 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
) {
40-137
471 if (ctx->tmp_len != 0
ctx->tmp_len != 0Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • base64test
FALSEevaluated 23 times by 1 test
Evaluated by:
  • base64test
) {
17-23
472 ctx->buf_len = EVP_EncodeBlock(-
473 (unsigned char *)ctx->buf,-
474 (unsigned char *)ctx->tmp,-
475 ctx->tmp_len);-
476 ctx->buf_off = 0;-
477 ctx->tmp_len = 0;-
478 goto
executed 17 times by 1 test: goto again;
Executed by:
  • base64test
again;
executed 17 times by 1 test: goto again;
Executed by:
  • base64test
17
479 }-
480 }
executed 23 times by 1 test: end of block
Executed by:
  • base64test
else if (ctx->encode != 0
ctx->encode != 0Description
TRUEevaluated 137 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEnever evaluated
&& ctx->base64.num != 0
ctx->base64.num != 0Description
TRUEevaluated 57 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
FALSEevaluated 80 times by 2 tests
Evaluated by:
  • base64test
  • libcrypto.so.44.0.1
) {
0-137
481 ctx->buf_off = 0;-
482 EVP_EncodeFinal(&(ctx->base64),-
483 (unsigned char *)ctx->buf,-
484 &(ctx->buf_len));-
485-
486 goto
executed 57 times by 2 tests: goto again;
Executed by:
  • base64test
  • libcrypto.so.44.0.1
again;
executed 57 times by 2 tests: goto again;
Executed by:
  • base64test
  • libcrypto.so.44.0.1
57
487 }-
488-
489 ret = BIO_ctrl(b->next_bio, cmd, num, ptr);-
490 break;
executed 103 times by 2 tests: break;
Executed by:
  • base64test
  • libcrypto.so.44.0.1
103
491-
492 case
never executed: case 101:
101:
never executed: case 101:
0
493 BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08));-
494 ret = BIO_ctrl(b->next_bio, cmd, num, ptr);-
495 BIO_copy_next_retry(b);-
496 break;
never executed: break;
0
497-
498 case
never executed: case 12:
12:
never executed: case 12:
0
499 break;
never executed: break;
0
500 case
executed 53 times by 1 test: case 3:
Executed by:
  • base64test
3:
executed 53 times by 1 test: case 3:
Executed by:
  • base64test
53
501 case
never executed: case 5:
5:
never executed: case 5:
0
502 case
never executed: case 4:
4:
never executed: case 4:
0
503 default
executed 302 times by 2 tests: default:
Executed by:
  • base64test
  • libcrypto.so.44.0.1
:
executed 302 times by 2 tests: default:
Executed by:
  • base64test
  • libcrypto.so.44.0.1
302
504 ret = BIO_ctrl(b->next_bio, cmd, num, ptr);-
505 break;
executed 355 times by 2 tests: break;
Executed by:
  • base64test
  • libcrypto.so.44.0.1
355
506 }-
507 return
executed 458 times by 2 tests: return (ret);
Executed by:
  • base64test
  • libcrypto.so.44.0.1
(ret);
executed 458 times by 2 tests: return (ret);
Executed by:
  • base64test
  • libcrypto.so.44.0.1
458
508}-
509-
510static long-
511b64_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp)-
512{-
513 long ret = 1;-
514-
515 if (b->next_bio ==
b->next_bio == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
516 ((void *)0)
b->next_bio == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
517 )-
518 return
never executed: return (0);
(0);
never executed: return (0);
0
519 switch (cmd) {-
520 default
never executed: default:
:
never executed: default:
0
521 ret = BIO_callback_ctrl(b->next_bio, cmd, fp);-
522 break;
never executed: break;
0
523 }-
524 return
never executed: return (ret);
(ret);
never executed: return (ret);
0
525}-
526-
527static int-
528b64_puts(BIO *b, const char *str)-
529{-
530 return
never executed: return b64_write(b, str, strlen(str));
b64_write(b, str, strlen(str));
never executed: return b64_write(b, str, strlen(str));
0
531}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2