OpenCoverage

base64.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssh/src/openbsd-compat/base64.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13-
14-
15static const char Base64[] =-
16 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";-
17static const char Pad64 = '=';-
18int-
19-
20__b64_ntop-
21(u_char const *src,size_t srclength,char *target,size_t targsize)-
22{-
23 size_t datalength = 0;-
24 u_char input[3];-
25 u_char output[4];-
26 u_int i;-
27-
28 while (2 < srclength
2 < srclengthDescription
TRUEevaluated 10315 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
FALSEevaluated 873 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
) {
873-10315
29 input[0] = *src++;-
30 input[1] = *src++;-
31 input[2] = *src++;-
32 srclength -= 3;-
33-
34 output[0] = input[0] >> 2;-
35 output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);-
36 output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);-
37 output[3] = input[2] & 0x3f;-
38-
39 if (datalength + 4 > targsize
datalength + 4 > targsizeDescription
TRUEnever evaluated
FALSEevaluated 10315 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
)
0-10315
40 return
never executed: return (-1);
(-1);
never executed: return (-1);
0
41 target[datalength++] = Base64[output[0]];-
42 target[datalength++] = Base64[output[1]];-
43 target[datalength++] = Base64[output[2]];-
44 target[datalength++] = Base64[output[3]];-
45 }
executed 10315 times by 5 tests: end of block
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
10315
46-
47-
48 if (0 != srclength
0 != srclengthDescription
TRUEevaluated 863 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
FALSEevaluated 10 times by 2 tests
Evaluated by:
  • ssh-keygen
  • test_sshbuf
) {
10-863
49-
50 input[0] = input[1] = input[2] = '\0';-
51 for (i = 0; i < srclength
i < srclengthDescription
TRUEevaluated 1721 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
FALSEevaluated 863 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
; i++)
863-1721
52 input[i] = *src++;
executed 1721 times by 5 tests: input[i] = *src++;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
1721
53-
54 output[0] = input[0] >> 2;-
55 output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);-
56 output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);-
57-
58 if (datalength + 4 > targsize
datalength + 4 > targsizeDescription
TRUEnever evaluated
FALSEevaluated 863 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
)
0-863
59 return
never executed: return (-1);
(-1);
never executed: return (-1);
0
60 target[datalength++] = Base64[output[0]];-
61 target[datalength++] = Base64[output[1]];-
62 if (srclength == 1
srclength == 1Description
TRUEevaluated 5 times by 2 tests
Evaluated by:
  • ssh-keygen
  • test_sshbuf
FALSEevaluated 858 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
)
5-858
63 target[datalength++] = Pad64;
executed 5 times by 2 tests: target[datalength++] = Pad64;
Executed by:
  • ssh-keygen
  • test_sshbuf
5
64 else-
65 target[datalength++] = Base64[output[2]];
executed 858 times by 5 tests: target[datalength++] = Base64[output[2]];
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
858
66 target[datalength++] = Pad64;-
67 }
executed 863 times by 5 tests: end of block
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
863
68 if (datalength >= targsize
datalength >= targsizeDescription
TRUEnever evaluated
FALSEevaluated 873 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
)
0-873
69 return
never executed: return (-1);
(-1);
never executed: return (-1);
0
70 target[datalength] = '\0';-
71 return
executed 873 times by 5 tests: return (datalength);
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
(datalength);
executed 873 times by 5 tests: return (datalength);
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
873
72}-
73int-
74-
75__b64_pton-
76(char const *src,u_char *target,size_t targsize)-
77{-
78 u_int tarindex, state;-
79 int ch;-
80 char *pos;-
81-
82 state = 0;-
83 tarindex = 0;-
84-
85 while ((
(ch = *src++) != '\0'Description
TRUEevaluated 7506067 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
FALSEevaluated 186 times by 4 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshkey
ch = *src++) != '\0'
(ch = *src++) != '\0'Description
TRUEevaluated 7506067 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
FALSEevaluated 186 times by 4 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshkey
) {
186-7506067
86 if (-
87 ((*
((*__ctype_b_l...int) _ISspace)Description
TRUEnever evaluated
FALSEevaluated 7506067 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
__ctype_b_loc ())[(int) ((
((*__ctype_b_l...int) _ISspace)Description
TRUEnever evaluated
FALSEevaluated 7506067 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
0-7506067
88 ch
((*__ctype_b_l...int) _ISspace)Description
TRUEnever evaluated
FALSEevaluated 7506067 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
0-7506067
89 ))] & (unsigned short int) _ISspace)
((*__ctype_b_l...int) _ISspace)Description
TRUEnever evaluated
FALSEevaluated 7506067 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
0-7506067
90 )-
91 continue;
never executed: continue;
0
92-
93 if (ch == Pad64
ch == Pad64Description
TRUEevaluated 22734 times by 4 tests
Evaluated by:
  • ssh-keygen
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
FALSEevaluated 7483333 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
)
22734-7483333
94 break;
executed 22734 times by 4 tests: break;
Executed by:
  • ssh-keygen
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
22734
95-
96 pos = -
97 (__extension__ (__builtin_constant_p (
__builtin_constant_p ( ch )Description
TRUEnever evaluated
FALSEevaluated 7483333 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
0-7483333
98 ch
__builtin_constant_p ( ch )Description
TRUEnever evaluated
FALSEevaluated 7483333 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
0-7483333
99 )
__builtin_constant_p ( ch )Description
TRUEnever evaluated
FALSEevaluated 7483333 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
&& !__builtin_constant_p (
!__builtin_con...t_p ( Base64 )Description
TRUEnever evaluated
FALSEnever evaluated
0-7483333
100 Base64
!__builtin_con...t_p ( Base64 )Description
TRUEnever evaluated
FALSEnever evaluated
0
101 )
!__builtin_con...t_p ( Base64 )Description
TRUEnever evaluated
FALSEnever evaluated
&& (
( ch ) == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
102 ch
( ch ) == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
103 ) == '\0'
( ch ) == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
? (char *) __rawmemchr (
0
104 Base64-
105 , -
106 ch-
107 ) : __builtin_strchr (-
108 Base64-
109 , -
110 ch-
111 )))-
112 ;-
113 if (pos == 0
pos == 0Description
TRUEnever evaluated
FALSEevaluated 7483333 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
)
0-7483333
114 return
never executed: return (-1);
(-1);
never executed: return (-1);
0
115-
116 switch (state) {-
117 case
executed 1881972 times by 5 tests: case 0:
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
0:
executed 1881972 times by 5 tests: case 0:
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
1881972
118 if (target
targetDescription
TRUEevaluated 1881972 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
FALSEnever evaluated
) {
0-1881972
119 if (tarindex >= targsize
tarindex >= targsizeDescription
TRUEnever evaluated
FALSEevaluated 1881972 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
)
0-1881972
120 return
never executed: return (-1);
(-1);
never executed: return (-1);
0
121 target[tarindex] = (pos - Base64) << 2;-
122 }
executed 1881972 times by 5 tests: end of block
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
1881972
123 state = 1;-
124 break;
executed 1881972 times by 5 tests: break;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
1881972
125 case
executed 1881972 times by 5 tests: case 1:
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
1:
executed 1881972 times by 5 tests: case 1:
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
1881972
126 if (target
targetDescription
TRUEevaluated 1881972 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
FALSEnever evaluated
) {
0-1881972
127 if (tarindex + 1 >= targsize
tarindex + 1 >= targsizeDescription
TRUEnever evaluated
FALSEevaluated 1881972 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
)
0-1881972
128 return
never executed: return (-1);
(-1);
never executed: return (-1);
0
129 target[tarindex] |= (pos - Base64) >> 4;-
130 target[tarindex+1] = ((pos - Base64) & 0x0f)-
131 << 4 ;-
132 }
executed 1881972 times by 5 tests: end of block
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
1881972
133 tarindex++;-
134 state = 2;-
135 break;
executed 1881972 times by 5 tests: break;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
1881972
136 case
executed 1860151 times by 5 tests: case 2:
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
2:
executed 1860151 times by 5 tests: case 2:
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
1860151
137 if (target
targetDescription
TRUEevaluated 1860151 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
FALSEnever evaluated
) {
0-1860151
138 if (tarindex + 1 >= targsize
tarindex + 1 >= targsizeDescription
TRUEnever evaluated
FALSEevaluated 1860151 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
)
0-1860151
139 return
never executed: return (-1);
(-1);
never executed: return (-1);
0
140 target[tarindex] |= (pos - Base64) >> 2;-
141 target[tarindex+1] = ((pos - Base64) & 0x03)-
142 << 6;-
143 }
executed 1860151 times by 5 tests: end of block
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
1860151
144 tarindex++;-
145 state = 3;-
146 break;
executed 1860151 times by 5 tests: break;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
1860151
147 case
executed 1859238 times by 5 tests: case 3:
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
3:
executed 1859238 times by 5 tests: case 3:
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
1859238
148 if (target
targetDescription
TRUEevaluated 1859238 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
FALSEnever evaluated
) {
0-1859238
149 if (tarindex >= targsize
tarindex >= targsizeDescription
TRUEnever evaluated
FALSEevaluated 1859238 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
)
0-1859238
150 return
never executed: return (-1);
(-1);
never executed: return (-1);
0
151 target[tarindex] |= (pos - Base64);-
152 }
executed 1859238 times by 5 tests: end of block
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
1859238
153 tarindex++;-
154 state = 0;-
155 break;
executed 1859238 times by 5 tests: break;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
1859238
156 }-
157 }
executed 7483333 times by 5 tests: end of block
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
7483333
158-
159-
160-
161-
162-
163-
164 if (ch == Pad64
ch == Pad64Description
TRUEevaluated 22734 times by 4 tests
Evaluated by:
  • ssh-keygen
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
FALSEevaluated 186 times by 4 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshkey
) {
186-22734
165 ch = *src++;-
166 switch (state) {-
167 case
never executed: case 0:
0:
never executed: case 0:
0
168 case
never executed: case 1:
1:
never executed: case 1:
0
169 return
never executed: return (-1);
(-1);
never executed: return (-1);
0
170-
171 case
executed 21821 times by 4 tests: case 2:
Executed by:
  • ssh-keygen
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
2:
executed 21821 times by 4 tests: case 2:
Executed by:
  • ssh-keygen
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
21821
172-
173 for (; ch != '\0'
ch != '\0'Description
TRUEevaluated 21821 times by 4 tests
Evaluated by:
  • ssh-keygen
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
FALSEnever evaluated
; ch = *src++)
0-21821
174 if (!
! ((*__ctype_b...int) _ISspace)Description
TRUEevaluated 21821 times by 4 tests
Evaluated by:
  • ssh-keygen
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
FALSEnever evaluated
0-21821
175 ((*__ctype_b_loc ())[(int) ((
! ((*__ctype_b...int) _ISspace)Description
TRUEevaluated 21821 times by 4 tests
Evaluated by:
  • ssh-keygen
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
FALSEnever evaluated
0-21821
176 ch
! ((*__ctype_b...int) _ISspace)Description
TRUEevaluated 21821 times by 4 tests
Evaluated by:
  • ssh-keygen
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
FALSEnever evaluated
0-21821
177 ))] & (unsigned short int) _ISspace)
! ((*__ctype_b...int) _ISspace)Description
TRUEevaluated 21821 times by 4 tests
Evaluated by:
  • ssh-keygen
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
FALSEnever evaluated
0-21821
178 )-
179 break;
executed 21821 times by 4 tests: break;
Executed by:
  • ssh-keygen
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
21821
180-
181 if (ch != Pad64
ch != Pad64Description
TRUEevaluated 64 times by 1 test
Evaluated by:
  • test_sshkey
FALSEevaluated 21757 times by 4 tests
Evaluated by:
  • ssh-keygen
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
)
64-21757
182 return
executed 64 times by 1 test: return (-1);
Executed by:
  • test_sshkey
(-1);
executed 64 times by 1 test: return (-1);
Executed by:
  • test_sshkey
64
183 ch = *src++;-
184-
185-
186-
187 case
executed 913 times by 4 tests: case 3:
Executed by:
  • ssh-keygen
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
3:
executed 913 times by 4 tests: case 3:
Executed by:
  • ssh-keygen
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
code before this statement executed 21757 times by 4 tests: case 3:
Executed by:
  • ssh-keygen
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
913-21757
188-
189-
190-
191-
192 for (; ch != '\0'
ch != '\0'Description
TRUEevaluated 257 times by 2 tests
Evaluated by:
  • ssh-keygen
  • test_sshkey
FALSEevaluated 22414 times by 4 tests
Evaluated by:
  • ssh-keygen
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
; ch = *src++)
257-22414
193 if (!
! ((*__ctype_b...int) _ISspace)Description
TRUEevaluated 256 times by 1 test
Evaluated by:
  • test_sshkey
FALSEevaluated 1 time by 1 test
Evaluated by:
  • ssh-keygen
1-256
194 ((*__ctype_b_loc ())[(int) ((
! ((*__ctype_b...int) _ISspace)Description
TRUEevaluated 256 times by 1 test
Evaluated by:
  • test_sshkey
FALSEevaluated 1 time by 1 test
Evaluated by:
  • ssh-keygen
1-256
195 ch
! ((*__ctype_b...int) _ISspace)Description
TRUEevaluated 256 times by 1 test
Evaluated by:
  • test_sshkey
FALSEevaluated 1 time by 1 test
Evaluated by:
  • ssh-keygen
1-256
196 ))] & (unsigned short int) _ISspace)
! ((*__ctype_b...int) _ISspace)Description
TRUEevaluated 256 times by 1 test
Evaluated by:
  • test_sshkey
FALSEevaluated 1 time by 1 test
Evaluated by:
  • ssh-keygen
1-256
197 )-
198 return
executed 256 times by 1 test: return (-1);
Executed by:
  • test_sshkey
(-1);
executed 256 times by 1 test: return (-1);
Executed by:
  • test_sshkey
256
199-
200-
201-
202-
203-
204-
205-
206 if (target
targetDescription
TRUEevaluated 22414 times by 4 tests
Evaluated by:
  • ssh-keygen
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
FALSEnever evaluated
&& target[tarindex] != 0
target[tarindex] != 0Description
TRUEevaluated 108 times by 1 test
Evaluated by:
  • test_sshkey
FALSEevaluated 22306 times by 4 tests
Evaluated by:
  • ssh-keygen
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
)
0-22414
207 return
executed 108 times by 1 test: return (-1);
Executed by:
  • test_sshkey
(-1);
executed 108 times by 1 test: return (-1);
Executed by:
  • test_sshkey
108
208 }
executed 22306 times by 4 tests: end of block
Executed by:
  • ssh-keygen
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
22306
209 }
executed 22306 times by 4 tests: end of block
Executed by:
  • ssh-keygen
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
else {
22306
210-
211-
212-
213-
214 if (state != 0
state != 0Description
TRUEnever evaluated
FALSEevaluated 186 times by 4 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshkey
)
0-186
215 return
never executed: return (-1);
(-1);
never executed: return (-1);
0
216 }
executed 186 times by 4 tests: end of block
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshkey
186
217-
218 return
executed 22492 times by 5 tests: return (tarindex);
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
(tarindex);
executed 22492 times by 5 tests: return (tarindex);
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
22492
219}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2