Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssh/src/openbsd-compat/base64.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | - | |||||||||||||
8 | - | |||||||||||||
9 | - | |||||||||||||
10 | - | |||||||||||||
11 | - | |||||||||||||
12 | - | |||||||||||||
13 | - | |||||||||||||
14 | - | |||||||||||||
15 | static const char Base64[] = | - | ||||||||||||
16 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | - | ||||||||||||
17 | static const char Pad64 = '='; | - | ||||||||||||
18 | int | - | ||||||||||||
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
| 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
| 0-10315 | ||||||||||||
40 | return never executed: (-1);return (-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:
| 10315 | ||||||||||||
46 | - | |||||||||||||
47 | - | |||||||||||||
48 | if (0 != srclength
| 10-863 | ||||||||||||
49 | - | |||||||||||||
50 | input[0] = input[1] = input[2] = '\0'; | - | ||||||||||||
51 | for (i = 0; i < srclength
| 863-1721 | ||||||||||||
52 | input[i] = *src++; executed 1721 times by 5 tests: input[i] = *src++; Executed by:
| 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
| 0-863 | ||||||||||||
59 | return never executed: (-1);return (-1); never executed: return (-1); | 0 | ||||||||||||
60 | target[datalength++] = Base64[output[0]]; | - | ||||||||||||
61 | target[datalength++] = Base64[output[1]]; | - | ||||||||||||
62 | if (srclength == 1
| 5-858 | ||||||||||||
63 | target[datalength++] = Pad64; executed 5 times by 2 tests: target[datalength++] = Pad64; Executed by:
| 5 | ||||||||||||
64 | else | - | ||||||||||||
65 | target[datalength++] = Base64[output[2]]; executed 858 times by 5 tests: target[datalength++] = Base64[output[2]]; Executed by:
| 858 | ||||||||||||
66 | target[datalength++] = Pad64; | - | ||||||||||||
67 | } executed 863 times by 5 tests: end of block Executed by:
| 863 | ||||||||||||
68 | if (datalength >= targsize
| 0-873 | ||||||||||||
69 | return never executed: (-1);return (-1); never executed: return (-1); | 0 | ||||||||||||
70 | target[datalength] = '\0'; | - | ||||||||||||
71 | return executed 873 times by 5 tests: (datalength);return (datalength); Executed by:
executed 873 times by 5 tests: return (datalength); Executed by:
| 873 | ||||||||||||
72 | } | - | ||||||||||||
73 | int | - | ||||||||||||
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 ((
| 186-7506067 | ||||||||||||
86 | if ( | - | ||||||||||||
87 | ((*
| 0-7506067 | ||||||||||||
88 | ch
| 0-7506067 | ||||||||||||
89 | ))] & (unsigned short int) _ISspace)
| 0-7506067 | ||||||||||||
90 | ) | - | ||||||||||||
91 | continue; never executed: continue; | 0 | ||||||||||||
92 | - | |||||||||||||
93 | if (ch == Pad64
| 22734-7483333 | ||||||||||||
94 | break; executed 22734 times by 4 tests: break; Executed by:
| 22734 | ||||||||||||
95 | - | |||||||||||||
96 | pos = | - | ||||||||||||
97 | (__extension__ (__builtin_constant_p (
| 0-7483333 | ||||||||||||
98 | ch
| 0-7483333 | ||||||||||||
99 | )
| 0-7483333 | ||||||||||||
100 | Base64
| 0 | ||||||||||||
101 | )
| 0 | ||||||||||||
102 | ch
| 0 | ||||||||||||
103 | ) == '\0'
| 0 | ||||||||||||
104 | Base64 | - | ||||||||||||
105 | , | - | ||||||||||||
106 | ch | - | ||||||||||||
107 | ) : __builtin_strchr ( | - | ||||||||||||
108 | Base64 | - | ||||||||||||
109 | , | - | ||||||||||||
110 | ch | - | ||||||||||||
111 | ))) | - | ||||||||||||
112 | ; | - | ||||||||||||
113 | if (pos == 0
| 0-7483333 | ||||||||||||
114 | return never executed: (-1);return (-1); never executed: return (-1); | 0 | ||||||||||||
115 | - | |||||||||||||
116 | switch (state) { | - | ||||||||||||
117 | case executed 1881972 times by 5 tests: 0:case 0: Executed by:
executed 1881972 times by 5 tests: case 0: Executed by:
| 1881972 | ||||||||||||
118 | if (target
| 0-1881972 | ||||||||||||
119 | if (tarindex >= targsize
| 0-1881972 | ||||||||||||
120 | return never executed: (-1);return (-1); never executed: return (-1); | 0 | ||||||||||||
121 | target[tarindex] = (pos - Base64) << 2; | - | ||||||||||||
122 | } executed 1881972 times by 5 tests: end of block Executed by:
| 1881972 | ||||||||||||
123 | state = 1; | - | ||||||||||||
124 | break; executed 1881972 times by 5 tests: break; Executed by:
| 1881972 | ||||||||||||
125 | case executed 1881972 times by 5 tests: 1:case 1: Executed by:
executed 1881972 times by 5 tests: case 1: Executed by:
| 1881972 | ||||||||||||
126 | if (target
| 0-1881972 | ||||||||||||
127 | if (tarindex + 1 >= targsize
| 0-1881972 | ||||||||||||
128 | return never executed: (-1);return (-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:
| 1881972 | ||||||||||||
133 | tarindex++; | - | ||||||||||||
134 | state = 2; | - | ||||||||||||
135 | break; executed 1881972 times by 5 tests: break; Executed by:
| 1881972 | ||||||||||||
136 | case executed 1860151 times by 5 tests: 2:case 2: Executed by:
executed 1860151 times by 5 tests: case 2: Executed by:
| 1860151 | ||||||||||||
137 | if (target
| 0-1860151 | ||||||||||||
138 | if (tarindex + 1 >= targsize
| 0-1860151 | ||||||||||||
139 | return never executed: (-1);return (-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:
| 1860151 | ||||||||||||
144 | tarindex++; | - | ||||||||||||
145 | state = 3; | - | ||||||||||||
146 | break; executed 1860151 times by 5 tests: break; Executed by:
| 1860151 | ||||||||||||
147 | case executed 1859238 times by 5 tests: 3:case 3: Executed by:
executed 1859238 times by 5 tests: case 3: Executed by:
| 1859238 | ||||||||||||
148 | if (target
| 0-1859238 | ||||||||||||
149 | if (tarindex >= targsize
| 0-1859238 | ||||||||||||
150 | return never executed: (-1);return (-1); never executed: return (-1); | 0 | ||||||||||||
151 | target[tarindex] |= (pos - Base64); | - | ||||||||||||
152 | } executed 1859238 times by 5 tests: end of block Executed by:
| 1859238 | ||||||||||||
153 | tarindex++; | - | ||||||||||||
154 | state = 0; | - | ||||||||||||
155 | break; executed 1859238 times by 5 tests: break; Executed by:
| 1859238 | ||||||||||||
156 | } | - | ||||||||||||
157 | } executed 7483333 times by 5 tests: end of block Executed by:
| 7483333 | ||||||||||||
158 | - | |||||||||||||
159 | - | |||||||||||||
160 | - | |||||||||||||
161 | - | |||||||||||||
162 | - | |||||||||||||
163 | - | |||||||||||||
164 | if (ch == Pad64
| 186-22734 | ||||||||||||
165 | ch = *src++; | - | ||||||||||||
166 | switch (state) { | - | ||||||||||||
167 | case never executed: 0:case 0: never executed: case 0: | 0 | ||||||||||||
168 | case never executed: 1:case 1: never executed: case 1: | 0 | ||||||||||||
169 | return never executed: (-1);return (-1); never executed: return (-1); | 0 | ||||||||||||
170 | - | |||||||||||||
171 | case executed 21821 times by 4 tests: 2:case 2: Executed by:
executed 21821 times by 4 tests: case 2: Executed by:
| 21821 | ||||||||||||
172 | - | |||||||||||||
173 | for (; ch != '\0'
| 0-21821 | ||||||||||||
174 | if (!
| 0-21821 | ||||||||||||
175 | ((*__ctype_b_loc ())[(int) ((
| 0-21821 | ||||||||||||
176 | ch
| 0-21821 | ||||||||||||
177 | ))] & (unsigned short int) _ISspace)
| 0-21821 | ||||||||||||
178 | ) | - | ||||||||||||
179 | break; executed 21821 times by 4 tests: break; Executed by:
| 21821 | ||||||||||||
180 | - | |||||||||||||
181 | if (ch != Pad64
| 64-21757 | ||||||||||||
182 | return executed 64 times by 1 test: (-1);return (-1); Executed by:
executed 64 times by 1 test: return (-1); Executed by:
| 64 | ||||||||||||
183 | ch = *src++; | - | ||||||||||||
184 | - | |||||||||||||
185 | - | |||||||||||||
186 | - | |||||||||||||
187 | case executed 913 times by 4 tests: 3:case 3: Executed by:
executed 913 times by 4 tests: case 3: Executed by:
code before this statement executed 21757 times by 4 tests: case 3: Executed by:
| 913-21757 | ||||||||||||
188 | - | |||||||||||||
189 | - | |||||||||||||
190 | - | |||||||||||||
191 | - | |||||||||||||
192 | for (; ch != '\0'
| 257-22414 | ||||||||||||
193 | if (!
| 1-256 | ||||||||||||
194 | ((*__ctype_b_loc ())[(int) ((
| 1-256 | ||||||||||||
195 | ch
| 1-256 | ||||||||||||
196 | ))] & (unsigned short int) _ISspace)
| 1-256 | ||||||||||||
197 | ) | - | ||||||||||||
198 | return executed 256 times by 1 test: (-1);return (-1); Executed by:
executed 256 times by 1 test: return (-1); Executed by:
| 256 | ||||||||||||
199 | - | |||||||||||||
200 | - | |||||||||||||
201 | - | |||||||||||||
202 | - | |||||||||||||
203 | - | |||||||||||||
204 | - | |||||||||||||
205 | - | |||||||||||||
206 | if (target
| 0-22414 | ||||||||||||
207 | return executed 108 times by 1 test: (-1);return (-1); Executed by:
executed 108 times by 1 test: return (-1); Executed by:
| 108 | ||||||||||||
208 | } executed 22306 times by 4 tests: end of block Executed by:
| 22306 | ||||||||||||
209 | } executed 22306 times by 4 tests: else {end of block Executed by:
| 22306 | ||||||||||||
210 | - | |||||||||||||
211 | - | |||||||||||||
212 | - | |||||||||||||
213 | - | |||||||||||||
214 | if (state != 0
| 0-186 | ||||||||||||
215 | return never executed: (-1);return (-1); never executed: return (-1); | 0 | ||||||||||||
216 | } executed 186 times by 4 tests: end of block Executed by:
| 186 | ||||||||||||
217 | - | |||||||||||||
218 | return executed 22492 times by 5 tests: (tarindex);return (tarindex); Executed by:
executed 22492 times by 5 tests: return (tarindex); Executed by:
| 22492 | ||||||||||||
219 | } | - | ||||||||||||
Switch to Source code | Preprocessed file |