Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssl/src/ssl/packet_locl.h |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | typedef struct { | - | ||||||||||||
3 | - | |||||||||||||
4 | const unsigned char *curr; | - | ||||||||||||
5 | - | |||||||||||||
6 | size_t remaining; | - | ||||||||||||
7 | } PACKET; | - | ||||||||||||
8 | - | |||||||||||||
9 | - | |||||||||||||
10 | static inline void packet_forward(PACKET *pkt, size_t len) | - | ||||||||||||
11 | { | - | ||||||||||||
12 | pkt->curr += len; | - | ||||||||||||
13 | pkt->remaining -= len; | - | ||||||||||||
14 | } executed 686115 times by 8 tests: end of block Executed by:
| 686115 | ||||||||||||
15 | - | |||||||||||||
16 | - | |||||||||||||
17 | - | |||||||||||||
18 | - | |||||||||||||
19 | static inline size_t PACKET_remaining(const PACKET *pkt) | - | ||||||||||||
20 | { | - | ||||||||||||
21 | return executed 890144 times by 8 tests: pkt->remaining;return pkt->remaining; Executed by:
executed 890144 times by 8 tests: return pkt->remaining; Executed by:
| 890144 | ||||||||||||
22 | } | - | ||||||||||||
23 | - | |||||||||||||
24 | - | |||||||||||||
25 | - | |||||||||||||
26 | - | |||||||||||||
27 | - | |||||||||||||
28 | - | |||||||||||||
29 | - | |||||||||||||
30 | static inline const unsigned char *PACKET_end(const PACKET *pkt) | - | ||||||||||||
31 | { | - | ||||||||||||
32 | return executed 29 times by 2 tests: pkt->curr + pkt->remaining;return pkt->curr + pkt->remaining; Executed by:
executed 29 times by 2 tests: return pkt->curr + pkt->remaining; Executed by:
| 29 | ||||||||||||
33 | } | - | ||||||||||||
34 | - | |||||||||||||
35 | - | |||||||||||||
36 | - | |||||||||||||
37 | - | |||||||||||||
38 | - | |||||||||||||
39 | static inline const unsigned char *PACKET_data(const PACKET *pkt) | - | ||||||||||||
40 | { | - | ||||||||||||
41 | return executed 18283 times by 3 tests: pkt->curr;return pkt->curr; Executed by:
executed 18283 times by 3 tests: return pkt->curr; Executed by:
| 18283 | ||||||||||||
42 | } | - | ||||||||||||
43 | - | |||||||||||||
44 | - | |||||||||||||
45 | - | |||||||||||||
46 | - | |||||||||||||
47 | - | |||||||||||||
48 | - | |||||||||||||
49 | static inline int PACKET_buf_init(PACKET *pkt, | - | ||||||||||||
50 | const unsigned char *buf, | - | ||||||||||||
51 | size_t len) | - | ||||||||||||
52 | { | - | ||||||||||||
53 | - | |||||||||||||
54 | if (len > (size_t)(
| 1-80687 | ||||||||||||
55 | (18446744073709551615UL)
| 1-80687 | ||||||||||||
56 | / 2)
| 1-80687 | ||||||||||||
57 | return executed 1 time by 1 test: 0;return 0; Executed by:
executed 1 time by 1 test: return 0; Executed by:
| 1 | ||||||||||||
58 | - | |||||||||||||
59 | pkt->curr = buf; | - | ||||||||||||
60 | pkt->remaining = len; | - | ||||||||||||
61 | return executed 80687 times by 8 tests: 1;return 1; Executed by:
executed 80687 times by 8 tests: return 1; Executed by:
| 80687 | ||||||||||||
62 | } | - | ||||||||||||
63 | - | |||||||||||||
64 | - | |||||||||||||
65 | static inline void PACKET_null_init(PACKET *pkt) | - | ||||||||||||
66 | { | - | ||||||||||||
67 | pkt->curr = | - | ||||||||||||
68 | ((void *)0) | - | ||||||||||||
69 | ; | - | ||||||||||||
70 | pkt->remaining = 0; | - | ||||||||||||
71 | } executed 6090 times by 2 tests: end of block Executed by:
| 6090 | ||||||||||||
72 | - | |||||||||||||
73 | - | |||||||||||||
74 | - | |||||||||||||
75 | - | |||||||||||||
76 | - | |||||||||||||
77 | - | |||||||||||||
78 | static inline int PACKET_equal(const PACKET *pkt, const void *ptr, | - | ||||||||||||
79 | size_t num) | - | ||||||||||||
80 | { | - | ||||||||||||
81 | if (PACKET_remaining(pkt) != num
| 7-46 | ||||||||||||
82 | return executed 7 times by 2 tests: 0;return 0; Executed by:
executed 7 times by 2 tests: return 0; Executed by:
| 7 | ||||||||||||
83 | return executed 46 times by 4 tests: CRYPTO_memcmp(pkt->curr, ptr, num) == 0;return CRYPTO_memcmp(pkt->curr, ptr, num) == 0; Executed by:
executed 46 times by 4 tests: return CRYPTO_memcmp(pkt->curr, ptr, num) == 0; Executed by:
| 46 | ||||||||||||
84 | } | - | ||||||||||||
85 | - | |||||||||||||
86 | - | |||||||||||||
87 | - | |||||||||||||
88 | - | |||||||||||||
89 | - | |||||||||||||
90 | - | |||||||||||||
91 | static inline int PACKET_peek_sub_packet(const PACKET *pkt, | - | ||||||||||||
92 | PACKET *subpkt, size_t len) | - | ||||||||||||
93 | { | - | ||||||||||||
94 | if (PACKET_remaining(pkt) < len
| 3-1620 | ||||||||||||
95 | return executed 3 times by 2 tests: 0;return 0; Executed by:
executed 3 times by 2 tests: return 0; Executed by:
| 3 | ||||||||||||
96 | - | |||||||||||||
97 | return executed 1620 times by 2 tests: PACKET_buf_init(subpkt, pkt->curr, len);return PACKET_buf_init(subpkt, pkt->curr, len); Executed by:
executed 1620 times by 2 tests: return PACKET_buf_init(subpkt, pkt->curr, len); Executed by:
| 1620 | ||||||||||||
98 | } | - | ||||||||||||
99 | - | |||||||||||||
100 | - | |||||||||||||
101 | - | |||||||||||||
102 | - | |||||||||||||
103 | - | |||||||||||||
104 | - | |||||||||||||
105 | static inline int PACKET_get_sub_packet(PACKET *pkt, | - | ||||||||||||
106 | PACKET *subpkt, size_t len) | - | ||||||||||||
107 | { | - | ||||||||||||
108 | if (!PACKET_peek_sub_packet(pkt, subpkt, len)
| 3-1620 | ||||||||||||
109 | return executed 3 times by 2 tests: 0;return 0; Executed by:
executed 3 times by 2 tests: return 0; Executed by:
| 3 | ||||||||||||
110 | - | |||||||||||||
111 | packet_forward(pkt, len); | - | ||||||||||||
112 | - | |||||||||||||
113 | return executed 1620 times by 2 tests: 1;return 1; Executed by:
executed 1620 times by 2 tests: return 1; Executed by:
| 1620 | ||||||||||||
114 | } | - | ||||||||||||
115 | - | |||||||||||||
116 | - | |||||||||||||
117 | - | |||||||||||||
118 | - | |||||||||||||
119 | - | |||||||||||||
120 | static inline int PACKET_peek_net_2(const PACKET *pkt, | - | ||||||||||||
121 | unsigned int *data) | - | ||||||||||||
122 | { | - | ||||||||||||
123 | if (PACKET_remaining(pkt) < 2
| 1473-343455 | ||||||||||||
124 | return executed 1473 times by 2 tests: 0;return 0; Executed by:
executed 1473 times by 2 tests: return 0; Executed by:
| 1473 | ||||||||||||
125 | - | |||||||||||||
126 | *data = ((unsigned int)(*pkt->curr)) << 8; | - | ||||||||||||
127 | *data |= *(pkt->curr + 1); | - | ||||||||||||
128 | - | |||||||||||||
129 | return executed 343455 times by 8 tests: 1;return 1; Executed by:
executed 343455 times by 8 tests: return 1; Executed by:
| 343455 | ||||||||||||
130 | } | - | ||||||||||||
131 | - | |||||||||||||
132 | - | |||||||||||||
133 | - | |||||||||||||
134 | static inline int PACKET_get_net_2(PACKET *pkt, unsigned int *data) | - | ||||||||||||
135 | { | - | ||||||||||||
136 | if (!PACKET_peek_net_2(pkt, data)
| 1473-343455 | ||||||||||||
137 | return executed 1473 times by 2 tests: 0;return 0; Executed by:
executed 1473 times by 2 tests: return 0; Executed by:
| 1473 | ||||||||||||
138 | - | |||||||||||||
139 | packet_forward(pkt, 2); | - | ||||||||||||
140 | - | |||||||||||||
141 | return executed 343455 times by 8 tests: 1;return 1; Executed by:
executed 343455 times by 8 tests: return 1; Executed by:
| 343455 | ||||||||||||
142 | } | - | ||||||||||||
143 | - | |||||||||||||
144 | - | |||||||||||||
145 | static inline int PACKET_get_net_2_len(PACKET *pkt, size_t *data) | - | ||||||||||||
146 | { | - | ||||||||||||
147 | unsigned int i; | - | ||||||||||||
148 | int ret = PACKET_get_net_2(pkt, &i); | - | ||||||||||||
149 | - | |||||||||||||
150 | if (ret
| 0-103335 | ||||||||||||
151 | * executed 103335 times by 1 test: data = (size_t)i;*data = (size_t)i; Executed by:
executed 103335 times by 1 test: *data = (size_t)i; Executed by:
| 103335 | ||||||||||||
152 | - | |||||||||||||
153 | return executed 103335 times by 1 test: ret;return ret; Executed by:
executed 103335 times by 1 test: return ret; Executed by:
| 103335 | ||||||||||||
154 | } | - | ||||||||||||
155 | - | |||||||||||||
156 | - | |||||||||||||
157 | - | |||||||||||||
158 | - | |||||||||||||
159 | - | |||||||||||||
160 | static inline int PACKET_peek_net_3(const PACKET *pkt, | - | ||||||||||||
161 | unsigned long *data) | - | ||||||||||||
162 | { | - | ||||||||||||
163 | if (PACKET_remaining(pkt) < 3
| 3-7079 | ||||||||||||
164 | return executed 3 times by 2 tests: 0;return 0; Executed by:
executed 3 times by 2 tests: return 0; Executed by:
| 3 | ||||||||||||
165 | - | |||||||||||||
166 | *data = ((unsigned long)(*pkt->curr)) << 16; | - | ||||||||||||
167 | *data |= ((unsigned long)(*(pkt->curr + 1))) << 8; | - | ||||||||||||
168 | *data |= *(pkt->curr + 2); | - | ||||||||||||
169 | - | |||||||||||||
170 | return executed 7079 times by 3 tests: 1;return 1; Executed by:
executed 7079 times by 3 tests: return 1; Executed by:
| 7079 | ||||||||||||
171 | } | - | ||||||||||||
172 | - | |||||||||||||
173 | - | |||||||||||||
174 | - | |||||||||||||
175 | static inline int PACKET_get_net_3(PACKET *pkt, unsigned long *data) | - | ||||||||||||
176 | { | - | ||||||||||||
177 | if (!PACKET_peek_net_3(pkt, data)
| 3-7079 | ||||||||||||
178 | return executed 3 times by 2 tests: 0;return 0; Executed by:
executed 3 times by 2 tests: return 0; Executed by:
| 3 | ||||||||||||
179 | - | |||||||||||||
180 | packet_forward(pkt, 3); | - | ||||||||||||
181 | - | |||||||||||||
182 | return executed 7079 times by 3 tests: 1;return 1; Executed by:
executed 7079 times by 3 tests: return 1; Executed by:
| 7079 | ||||||||||||
183 | } | - | ||||||||||||
184 | - | |||||||||||||
185 | - | |||||||||||||
186 | static inline int PACKET_get_net_3_len(PACKET *pkt, size_t *data) | - | ||||||||||||
187 | { | - | ||||||||||||
188 | unsigned long i; | - | ||||||||||||
189 | int ret = PACKET_get_net_3(pkt, &i); | - | ||||||||||||
190 | - | |||||||||||||
191 | if (ret
| 0-35 | ||||||||||||
192 | * executed 35 times by 1 test: data = (size_t)i;*data = (size_t)i; Executed by:
executed 35 times by 1 test: *data = (size_t)i; Executed by:
| 35 | ||||||||||||
193 | - | |||||||||||||
194 | return executed 35 times by 1 test: ret;return ret; Executed by:
executed 35 times by 1 test: return ret; Executed by:
| 35 | ||||||||||||
195 | } | - | ||||||||||||
196 | - | |||||||||||||
197 | - | |||||||||||||
198 | - | |||||||||||||
199 | - | |||||||||||||
200 | - | |||||||||||||
201 | static inline int PACKET_peek_net_4(const PACKET *pkt, | - | ||||||||||||
202 | unsigned long *data) | - | ||||||||||||
203 | { | - | ||||||||||||
204 | if (PACKET_remaining(pkt) < 4
| 3-3198 | ||||||||||||
205 | return executed 3 times by 2 tests: 0;return 0; Executed by:
executed 3 times by 2 tests: return 0; Executed by:
| 3 | ||||||||||||
206 | - | |||||||||||||
207 | *data = ((unsigned long)(*pkt->curr)) << 24; | - | ||||||||||||
208 | *data |= ((unsigned long)(*(pkt->curr + 1))) << 16; | - | ||||||||||||
209 | *data |= ((unsigned long)(*(pkt->curr + 2))) << 8; | - | ||||||||||||
210 | *data |= *(pkt->curr + 3); | - | ||||||||||||
211 | - | |||||||||||||
212 | return executed 3198 times by 2 tests: 1;return 1; Executed by:
executed 3198 times by 2 tests: return 1; Executed by:
| 3198 | ||||||||||||
213 | } | - | ||||||||||||
214 | - | |||||||||||||
215 | - | |||||||||||||
216 | - | |||||||||||||
217 | static inline int PACKET_get_net_4(PACKET *pkt, unsigned long *data) | - | ||||||||||||
218 | { | - | ||||||||||||
219 | if (!PACKET_peek_net_4(pkt, data)
| 3-3198 | ||||||||||||
220 | return executed 3 times by 2 tests: 0;return 0; Executed by:
executed 3 times by 2 tests: return 0; Executed by:
| 3 | ||||||||||||
221 | - | |||||||||||||
222 | packet_forward(pkt, 4); | - | ||||||||||||
223 | - | |||||||||||||
224 | return executed 3198 times by 2 tests: 1;return 1; Executed by:
executed 3198 times by 2 tests: return 1; Executed by:
| 3198 | ||||||||||||
225 | } | - | ||||||||||||
226 | - | |||||||||||||
227 | - | |||||||||||||
228 | static inline int PACKET_get_net_4_len(PACKET *pkt, size_t *data) | - | ||||||||||||
229 | { | - | ||||||||||||
230 | unsigned long i; | - | ||||||||||||
231 | int ret = PACKET_get_net_4(pkt, &i); | - | ||||||||||||
232 | - | |||||||||||||
233 | if (ret
| 0 | ||||||||||||
234 | * never executed: data = (size_t)i;*data = (size_t)i; never executed: *data = (size_t)i; | 0 | ||||||||||||
235 | - | |||||||||||||
236 | return never executed: ret;return ret; never executed: return ret; | 0 | ||||||||||||
237 | } | - | ||||||||||||
238 | - | |||||||||||||
239 | - | |||||||||||||
240 | static inline int PACKET_peek_1(const PACKET *pkt, | - | ||||||||||||
241 | unsigned int *data) | - | ||||||||||||
242 | { | - | ||||||||||||
243 | if (!PACKET_remaining(pkt)
| 863-142462 | ||||||||||||
244 | return executed 863 times by 3 tests: 0;return 0; Executed by:
executed 863 times by 3 tests: return 0; Executed by:
| 863 | ||||||||||||
245 | - | |||||||||||||
246 | *data = *pkt->curr; | - | ||||||||||||
247 | - | |||||||||||||
248 | return executed 142462 times by 8 tests: 1;return 1; Executed by:
executed 142462 times by 8 tests: return 1; Executed by:
| 142462 | ||||||||||||
249 | } | - | ||||||||||||
250 | - | |||||||||||||
251 | - | |||||||||||||
252 | static inline int PACKET_get_1(PACKET *pkt, unsigned int *data) | - | ||||||||||||
253 | { | - | ||||||||||||
254 | if (!PACKET_peek_1(pkt, data)
| 863-142462 | ||||||||||||
255 | return executed 863 times by 3 tests: 0;return 0; Executed by:
executed 863 times by 3 tests: return 0; Executed by:
| 863 | ||||||||||||
256 | - | |||||||||||||
257 | packet_forward(pkt, 1); | - | ||||||||||||
258 | - | |||||||||||||
259 | return executed 142462 times by 8 tests: 1;return 1; Executed by:
executed 142462 times by 8 tests: return 1; Executed by:
| 142462 | ||||||||||||
260 | } | - | ||||||||||||
261 | - | |||||||||||||
262 | - | |||||||||||||
263 | static inline int PACKET_get_1_len(PACKET *pkt, size_t *data) | - | ||||||||||||
264 | { | - | ||||||||||||
265 | unsigned int i; | - | ||||||||||||
266 | int ret = PACKET_get_1(pkt, &i); | - | ||||||||||||
267 | - | |||||||||||||
268 | if (ret
| 0-2506 | ||||||||||||
269 | * executed 2506 times by 1 test: data = (size_t)i;*data = (size_t)i; Executed by:
executed 2506 times by 1 test: *data = (size_t)i; Executed by:
| 2506 | ||||||||||||
270 | - | |||||||||||||
271 | return executed 2506 times by 1 test: ret;return ret; Executed by:
executed 2506 times by 1 test: return ret; Executed by:
| 2506 | ||||||||||||
272 | } | - | ||||||||||||
273 | - | |||||||||||||
274 | - | |||||||||||||
275 | - | |||||||||||||
276 | - | |||||||||||||
277 | - | |||||||||||||
278 | static inline int PACKET_peek_4(const PACKET *pkt, | - | ||||||||||||
279 | unsigned long *data) | - | ||||||||||||
280 | { | - | ||||||||||||
281 | if (PACKET_remaining(pkt) < 4
| 1-2 | ||||||||||||
282 | return executed 1 time by 1 test: 0;return 0; Executed by:
executed 1 time by 1 test: return 0; Executed by:
| 1 | ||||||||||||
283 | - | |||||||||||||
284 | *data = *pkt->curr; | - | ||||||||||||
285 | *data |= ((unsigned long)(*(pkt->curr + 1))) << 8; | - | ||||||||||||
286 | *data |= ((unsigned long)(*(pkt->curr + 2))) << 16; | - | ||||||||||||
287 | *data |= ((unsigned long)(*(pkt->curr + 3))) << 24; | - | ||||||||||||
288 | - | |||||||||||||
289 | return executed 2 times by 1 test: 1;return 1; Executed by:
executed 2 times by 1 test: return 1; Executed by:
| 2 | ||||||||||||
290 | } | - | ||||||||||||
291 | - | |||||||||||||
292 | - | |||||||||||||
293 | - | |||||||||||||
294 | - | |||||||||||||
295 | - | |||||||||||||
296 | - | |||||||||||||
297 | static inline int PACKET_get_4(PACKET *pkt, unsigned long *data) | - | ||||||||||||
298 | { | - | ||||||||||||
299 | if (!PACKET_peek_4(pkt, data)
| 1-2 | ||||||||||||
300 | return executed 1 time by 1 test: 0;return 0; Executed by:
executed 1 time by 1 test: return 0; Executed by:
| 1 | ||||||||||||
301 | - | |||||||||||||
302 | packet_forward(pkt, 4); | - | ||||||||||||
303 | - | |||||||||||||
304 | return executed 2 times by 1 test: 1;return 1; Executed by:
executed 2 times by 1 test: return 1; Executed by:
| 2 | ||||||||||||
305 | } | - | ||||||||||||
306 | - | |||||||||||||
307 | - | |||||||||||||
308 | - | |||||||||||||
309 | - | |||||||||||||
310 | - | |||||||||||||
311 | - | |||||||||||||
312 | - | |||||||||||||
313 | static inline int PACKET_peek_bytes(const PACKET *pkt, | - | ||||||||||||
314 | const unsigned char **data, | - | ||||||||||||
315 | size_t len) | - | ||||||||||||
316 | { | - | ||||||||||||
317 | if (PACKET_remaining(pkt) < len
| 154-99507 | ||||||||||||
318 | return executed 154 times by 2 tests: 0;return 0; Executed by:
executed 154 times by 2 tests: return 0; Executed by:
| 154 | ||||||||||||
319 | - | |||||||||||||
320 | *data = pkt->curr; | - | ||||||||||||
321 | - | |||||||||||||
322 | return executed 99507 times by 8 tests: 1;return 1; Executed by:
executed 99507 times by 8 tests: return 1; Executed by:
| 99507 | ||||||||||||
323 | } | - | ||||||||||||
324 | - | |||||||||||||
325 | - | |||||||||||||
326 | - | |||||||||||||
327 | - | |||||||||||||
328 | - | |||||||||||||
329 | - | |||||||||||||
330 | - | |||||||||||||
331 | static inline int PACKET_get_bytes(PACKET *pkt, | - | ||||||||||||
332 | const unsigned char **data, | - | ||||||||||||
333 | size_t len) | - | ||||||||||||
334 | { | - | ||||||||||||
335 | if (!PACKET_peek_bytes(pkt, data, len)
| 154-99507 | ||||||||||||
336 | return executed 154 times by 2 tests: 0;return 0; Executed by:
executed 154 times by 2 tests: return 0; Executed by:
| 154 | ||||||||||||
337 | - | |||||||||||||
338 | packet_forward(pkt, len); | - | ||||||||||||
339 | - | |||||||||||||
340 | return executed 99507 times by 8 tests: 1;return 1; Executed by:
executed 99507 times by 8 tests: return 1; Executed by:
| 99507 | ||||||||||||
341 | } | - | ||||||||||||
342 | - | |||||||||||||
343 | - | |||||||||||||
344 | static inline int PACKET_peek_copy_bytes(const PACKET *pkt, | - | ||||||||||||
345 | unsigned char *data, | - | ||||||||||||
346 | size_t len) | - | ||||||||||||
347 | { | - | ||||||||||||
348 | if (PACKET_remaining(pkt) < len
| 3137-87500 | ||||||||||||
349 | return executed 3137 times by 1 test: 0;return 0; Executed by:
executed 3137 times by 1 test: return 0; Executed by:
| 3137 | ||||||||||||
350 | - | |||||||||||||
351 | memcpy(data, pkt->curr, len); | - | ||||||||||||
352 | - | |||||||||||||
353 | return executed 87500 times by 4 tests: 1;return 1; Executed by:
executed 87500 times by 4 tests: return 1; Executed by:
| 87500 | ||||||||||||
354 | } | - | ||||||||||||
355 | - | |||||||||||||
356 | - | |||||||||||||
357 | - | |||||||||||||
358 | - | |||||||||||||
359 | - | |||||||||||||
360 | static inline int PACKET_copy_bytes(PACKET *pkt, | - | ||||||||||||
361 | unsigned char *data, size_t len) | - | ||||||||||||
362 | { | - | ||||||||||||
363 | if (!PACKET_peek_copy_bytes(pkt, data, len)
| 3137-87500 | ||||||||||||
364 | return executed 3137 times by 1 test: 0;return 0; Executed by:
executed 3137 times by 1 test: return 0; Executed by:
| 3137 | ||||||||||||
365 | - | |||||||||||||
366 | packet_forward(pkt, len); | - | ||||||||||||
367 | - | |||||||||||||
368 | return executed 87500 times by 4 tests: 1;return 1; Executed by:
executed 87500 times by 4 tests: return 1; Executed by:
| 87500 | ||||||||||||
369 | } | - | ||||||||||||
370 | static inline int PACKET_copy_all(const PACKET *pkt, | - | ||||||||||||
371 | unsigned char *dest, | - | ||||||||||||
372 | size_t dest_len, size_t *len) | - | ||||||||||||
373 | { | - | ||||||||||||
374 | if (PACKET_remaining(pkt) > dest_len
| 2-7406 | ||||||||||||
375 | *len = 0; | - | ||||||||||||
376 | return executed 2 times by 2 tests: 0;return 0; Executed by:
executed 2 times by 2 tests: return 0; Executed by:
| 2 | ||||||||||||
377 | } | - | ||||||||||||
378 | *len = pkt->remaining; | - | ||||||||||||
379 | memcpy(dest, pkt->curr, pkt->remaining); | - | ||||||||||||
380 | return executed 7406 times by 2 tests: 1;return 1; Executed by:
executed 7406 times by 2 tests: return 1; Executed by:
| 7406 | ||||||||||||
381 | } | - | ||||||||||||
382 | static inline int PACKET_memdup(const PACKET *pkt, | - | ||||||||||||
383 | unsigned char **data, size_t *len) | - | ||||||||||||
384 | { | - | ||||||||||||
385 | size_t length; | - | ||||||||||||
386 | - | |||||||||||||
387 | CRYPTO_free(*data, __FILE__, 420); | - | ||||||||||||
388 | *data = | - | ||||||||||||
389 | ((void *)0) | - | ||||||||||||
390 | ; | - | ||||||||||||
391 | *len = 0; | - | ||||||||||||
392 | - | |||||||||||||
393 | length = PACKET_remaining(pkt); | - | ||||||||||||
394 | - | |||||||||||||
395 | if (length == 0
| 42-4703 | ||||||||||||
396 | return executed 42 times by 1 test: 1;return 1; Executed by:
executed 42 times by 1 test: return 1; Executed by:
| 42 | ||||||||||||
397 | - | |||||||||||||
398 | *data = CRYPTO_memdup((pkt->curr), length, __FILE__, 429); | - | ||||||||||||
399 | if (*
| 0-4703 | ||||||||||||
400 | ((void *)0)
| 0-4703 | ||||||||||||
401 | ) | - | ||||||||||||
402 | return never executed: 0;return 0; never executed: return 0; | 0 | ||||||||||||
403 | - | |||||||||||||
404 | *len = length; | - | ||||||||||||
405 | return executed 4703 times by 2 tests: 1;return 1; Executed by:
executed 4703 times by 2 tests: return 1; Executed by:
| 4703 | ||||||||||||
406 | } | - | ||||||||||||
407 | static inline int PACKET_strndup(const PACKET *pkt, char **data) | - | ||||||||||||
408 | { | - | ||||||||||||
409 | CRYPTO_free(*data, __FILE__, 449); | - | ||||||||||||
410 | - | |||||||||||||
411 | - | |||||||||||||
412 | *data = CRYPTO_strndup((const char *)pkt->curr, PACKET_remaining(pkt), __FILE__, 452); | - | ||||||||||||
413 | return executed 647 times by 3 tests: (*data != return (*data != ((void *)0) ); Executed by:
executed 647 times by 3 tests: return (*data != ((void *)0) ); Executed by:
| 647 | ||||||||||||
414 | ((void *)0) executed 647 times by 3 tests: return (*data != ((void *)0) ); Executed by:
| 647 | ||||||||||||
415 | ); executed 647 times by 3 tests: return (*data != ((void *)0) ); Executed by:
| 647 | ||||||||||||
416 | } | - | ||||||||||||
417 | - | |||||||||||||
418 | - | |||||||||||||
419 | static inline int PACKET_contains_zero_byte(const PACKET *pkt) | - | ||||||||||||
420 | { | - | ||||||||||||
421 | return executed 610 times by 3 tests: memchr(pkt->curr, 0, pkt->remaining) != return memchr(pkt->curr, 0, pkt->remaining) != ((void *)0) ; Executed by:
executed 610 times by 3 tests: return memchr(pkt->curr, 0, pkt->remaining) != ((void *)0) ; Executed by:
| 610 | ||||||||||||
422 | ((void *)0) executed 610 times by 3 tests: return memchr(pkt->curr, 0, pkt->remaining) != ((void *)0) ; Executed by:
| 610 | ||||||||||||
423 | ; executed 610 times by 3 tests: return memchr(pkt->curr, 0, pkt->remaining) != ((void *)0) ; Executed by:
| 610 | ||||||||||||
424 | } | - | ||||||||||||
425 | - | |||||||||||||
426 | - | |||||||||||||
427 | static inline int PACKET_forward(PACKET *pkt, size_t len) | - | ||||||||||||
428 | { | - | ||||||||||||
429 | if (PACKET_remaining(pkt) < len
| 1-1292 | ||||||||||||
430 | return executed 1 time by 1 test: 0;return 0; Executed by:
executed 1 time by 1 test: return 0; Executed by:
| 1 | ||||||||||||
431 | - | |||||||||||||
432 | packet_forward(pkt, len); | - | ||||||||||||
433 | - | |||||||||||||
434 | return executed 1292 times by 8 tests: 1;return 1; Executed by:
executed 1292 times by 8 tests: return 1; Executed by:
| 1292 | ||||||||||||
435 | } | - | ||||||||||||
436 | static inline int PACKET_get_length_prefixed_1(PACKET *pkt, | - | ||||||||||||
437 | PACKET *subpkt) | - | ||||||||||||
438 | { | - | ||||||||||||
439 | unsigned int length; | - | ||||||||||||
440 | const unsigned char *data; | - | ||||||||||||
441 | PACKET tmp = *pkt; | - | ||||||||||||
442 | if (!PACKET_get_1(&tmp, &length)
| 9-14579 | ||||||||||||
443 | !PACKET_get_bytes(&tmp, &data, (size_t)length)
| 16-14563 | ||||||||||||
444 | return executed 25 times by 2 tests: 0;return 0; Executed by:
executed 25 times by 2 tests: return 0; Executed by:
| 25 | ||||||||||||
445 | } | - | ||||||||||||
446 | - | |||||||||||||
447 | *pkt = tmp; | - | ||||||||||||
448 | subpkt->curr = data; | - | ||||||||||||
449 | subpkt->remaining = length; | - | ||||||||||||
450 | - | |||||||||||||
451 | return executed 14563 times by 8 tests: 1;return 1; Executed by:
executed 14563 times by 8 tests: return 1; Executed by:
| 14563 | ||||||||||||
452 | } | - | ||||||||||||
453 | - | |||||||||||||
454 | - | |||||||||||||
455 | - | |||||||||||||
456 | - | |||||||||||||
457 | - | |||||||||||||
458 | static inline int PACKET_as_length_prefixed_1(PACKET *pkt, | - | ||||||||||||
459 | PACKET *subpkt) | - | ||||||||||||
460 | { | - | ||||||||||||
461 | unsigned int length; | - | ||||||||||||
462 | const unsigned char *data; | - | ||||||||||||
463 | PACKET tmp = *pkt; | - | ||||||||||||
464 | if (!PACKET_get_1(&tmp, &length)
| 6-4710 | ||||||||||||
465 | !PACKET_get_bytes(&tmp, &data, (size_t)length)
| 5-4705 | ||||||||||||
466 | PACKET_remaining(&tmp) != 0
| 4-4701 | ||||||||||||
467 | return executed 15 times by 2 tests: 0;return 0; Executed by:
executed 15 times by 2 tests: return 0; Executed by:
| 15 | ||||||||||||
468 | } | - | ||||||||||||
469 | - | |||||||||||||
470 | *pkt = tmp; | - | ||||||||||||
471 | subpkt->curr = data; | - | ||||||||||||
472 | subpkt->remaining = length; | - | ||||||||||||
473 | - | |||||||||||||
474 | return executed 4701 times by 2 tests: 1;return 1; Executed by:
executed 4701 times by 2 tests: return 1; Executed by:
| 4701 | ||||||||||||
475 | } | - | ||||||||||||
476 | static inline int PACKET_get_length_prefixed_2(PACKET *pkt, | - | ||||||||||||
477 | PACKET *subpkt) | - | ||||||||||||
478 | { | - | ||||||||||||
479 | unsigned int length; | - | ||||||||||||
480 | const unsigned char *data; | - | ||||||||||||
481 | PACKET tmp = *pkt; | - | ||||||||||||
482 | - | |||||||||||||
483 | if (!PACKET_get_net_2(&tmp, &length)
| 23-50631 | ||||||||||||
484 | !PACKET_get_bytes(&tmp, &data, (size_t)length)
| 82-50549 | ||||||||||||
485 | return executed 105 times by 2 tests: 0;return 0; Executed by:
executed 105 times by 2 tests: return 0; Executed by:
| 105 | ||||||||||||
486 | } | - | ||||||||||||
487 | - | |||||||||||||
488 | *pkt = tmp; | - | ||||||||||||
489 | subpkt->curr = data; | - | ||||||||||||
490 | subpkt->remaining = length; | - | ||||||||||||
491 | - | |||||||||||||
492 | return executed 50549 times by 7 tests: 1;return 1; Executed by:
executed 50549 times by 7 tests: return 1; Executed by:
| 50549 | ||||||||||||
493 | } | - | ||||||||||||
494 | - | |||||||||||||
495 | - | |||||||||||||
496 | - | |||||||||||||
497 | - | |||||||||||||
498 | - | |||||||||||||
499 | static inline int PACKET_as_length_prefixed_2(PACKET *pkt, | - | ||||||||||||
500 | PACKET *subpkt) | - | ||||||||||||
501 | { | - | ||||||||||||
502 | unsigned int length; | - | ||||||||||||
503 | const unsigned char *data; | - | ||||||||||||
504 | PACKET tmp = *pkt; | - | ||||||||||||
505 | - | |||||||||||||
506 | if (!PACKET_get_net_2(&tmp, &length)
| 13-14275 | ||||||||||||
507 | !PACKET_get_bytes(&tmp, &data, (size_t)length)
| 30-14245 | ||||||||||||
508 | PACKET_remaining(&tmp) != 0
| 9-14236 | ||||||||||||
509 | return executed 52 times by 2 tests: 0;return 0; Executed by:
executed 52 times by 2 tests: return 0; Executed by:
| 52 | ||||||||||||
510 | } | - | ||||||||||||
511 | - | |||||||||||||
512 | *pkt = tmp; | - | ||||||||||||
513 | subpkt->curr = data; | - | ||||||||||||
514 | subpkt->remaining = length; | - | ||||||||||||
515 | - | |||||||||||||
516 | return executed 14236 times by 5 tests: 1;return 1; Executed by:
executed 14236 times by 5 tests: return 1; Executed by:
| 14236 | ||||||||||||
517 | } | - | ||||||||||||
518 | static inline int PACKET_get_length_prefixed_3(PACKET *pkt, | - | ||||||||||||
519 | PACKET *subpkt) | - | ||||||||||||
520 | { | - | ||||||||||||
521 | unsigned long length; | - | ||||||||||||
522 | const unsigned char *data; | - | ||||||||||||
523 | PACKET tmp = *pkt; | - | ||||||||||||
524 | if (!PACKET_get_net_3(&tmp, &length)
| 0-137 | ||||||||||||
525 | !PACKET_get_bytes(&tmp, &data, (size_t)length)
| 1-136 | ||||||||||||
526 | return executed 1 time by 1 test: 0;return 0; Executed by:
executed 1 time by 1 test: return 0; Executed by:
| 1 | ||||||||||||
527 | } | - | ||||||||||||
528 | - | |||||||||||||
529 | *pkt = tmp; | - | ||||||||||||
530 | subpkt->curr = data; | - | ||||||||||||
531 | subpkt->remaining = length; | - | ||||||||||||
532 | - | |||||||||||||
533 | return executed 136 times by 3 tests: 1;return 1; Executed by:
executed 136 times by 3 tests: return 1; Executed by:
| 136 | ||||||||||||
534 | } | - | ||||||||||||
535 | - | |||||||||||||
536 | - | |||||||||||||
537 | - | |||||||||||||
538 | typedef struct wpacket_sub WPACKET_SUB; | - | ||||||||||||
539 | struct wpacket_sub { | - | ||||||||||||
540 | - | |||||||||||||
541 | WPACKET_SUB *parent; | - | ||||||||||||
542 | - | |||||||||||||
543 | - | |||||||||||||
544 | - | |||||||||||||
545 | - | |||||||||||||
546 | - | |||||||||||||
547 | size_t packet_len; | - | ||||||||||||
548 | - | |||||||||||||
549 | - | |||||||||||||
550 | size_t lenbytes; | - | ||||||||||||
551 | - | |||||||||||||
552 | - | |||||||||||||
553 | size_t pwritten; | - | ||||||||||||
554 | - | |||||||||||||
555 | - | |||||||||||||
556 | unsigned int flags; | - | ||||||||||||
557 | }; | - | ||||||||||||
558 | - | |||||||||||||
559 | typedef struct wpacket_st WPACKET; | - | ||||||||||||
560 | struct wpacket_st { | - | ||||||||||||
561 | - | |||||||||||||
562 | BUF_MEM *buf; | - | ||||||||||||
563 | - | |||||||||||||
564 | - | |||||||||||||
565 | unsigned char *staticbuf; | - | ||||||||||||
566 | - | |||||||||||||
567 | - | |||||||||||||
568 | - | |||||||||||||
569 | - | |||||||||||||
570 | - | |||||||||||||
571 | size_t curr; | - | ||||||||||||
572 | - | |||||||||||||
573 | - | |||||||||||||
574 | size_t written; | - | ||||||||||||
575 | - | |||||||||||||
576 | - | |||||||||||||
577 | size_t maxsize; | - | ||||||||||||
578 | - | |||||||||||||
579 | - | |||||||||||||
580 | WPACKET_SUB *subs; | - | ||||||||||||
581 | }; | - | ||||||||||||
582 | int WPACKET_init_len(WPACKET *pkt, BUF_MEM *buf, size_t lenbytes); | - | ||||||||||||
583 | - | |||||||||||||
584 | - | |||||||||||||
585 | - | |||||||||||||
586 | - | |||||||||||||
587 | - | |||||||||||||
588 | int WPACKET_init(WPACKET *pkt, BUF_MEM *buf); | - | ||||||||||||
589 | - | |||||||||||||
590 | - | |||||||||||||
591 | - | |||||||||||||
592 | - | |||||||||||||
593 | - | |||||||||||||
594 | - | |||||||||||||
595 | int WPACKET_init_static_len(WPACKET *pkt, unsigned char *buf, size_t len, | - | ||||||||||||
596 | size_t lenbytes); | - | ||||||||||||
597 | - | |||||||||||||
598 | - | |||||||||||||
599 | - | |||||||||||||
600 | int WPACKET_set_flags(WPACKET *pkt, unsigned int flags); | - | ||||||||||||
601 | - | |||||||||||||
602 | - | |||||||||||||
603 | - | |||||||||||||
604 | - | |||||||||||||
605 | - | |||||||||||||
606 | - | |||||||||||||
607 | - | |||||||||||||
608 | int WPACKET_close(WPACKET *pkt); | - | ||||||||||||
609 | - | |||||||||||||
610 | - | |||||||||||||
611 | - | |||||||||||||
612 | - | |||||||||||||
613 | - | |||||||||||||
614 | int WPACKET_finish(WPACKET *pkt); | - | ||||||||||||
615 | int WPACKET_fill_lengths(WPACKET *pkt); | - | ||||||||||||
616 | - | |||||||||||||
617 | - | |||||||||||||
618 | - | |||||||||||||
619 | - | |||||||||||||
620 | - | |||||||||||||
621 | - | |||||||||||||
622 | int WPACKET_start_sub_packet_len__(WPACKET *pkt, size_t lenbytes); | - | ||||||||||||
623 | int WPACKET_start_sub_packet(WPACKET *pkt); | - | ||||||||||||
624 | int WPACKET_allocate_bytes(WPACKET *pkt, size_t len, | - | ||||||||||||
625 | unsigned char **allocbytes); | - | ||||||||||||
626 | - | |||||||||||||
627 | - | |||||||||||||
628 | - | |||||||||||||
629 | - | |||||||||||||
630 | - | |||||||||||||
631 | - | |||||||||||||
632 | - | |||||||||||||
633 | int WPACKET_sub_allocate_bytes__(WPACKET *pkt, size_t len, | - | ||||||||||||
634 | unsigned char **allocbytes, size_t lenbytes); | - | ||||||||||||
635 | int WPACKET_reserve_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes); | - | ||||||||||||
636 | - | |||||||||||||
637 | - | |||||||||||||
638 | - | |||||||||||||
639 | - | |||||||||||||
640 | int WPACKET_sub_reserve_bytes__(WPACKET *pkt, size_t len, | - | ||||||||||||
641 | unsigned char **allocbytes, size_t lenbytes); | - | ||||||||||||
642 | int WPACKET_put_bytes__(WPACKET *pkt, unsigned int val, size_t bytes); | - | ||||||||||||
643 | int WPACKET_set_max_size(WPACKET *pkt, size_t maxsize); | - | ||||||||||||
644 | - | |||||||||||||
645 | - | |||||||||||||
646 | int WPACKET_memcpy(WPACKET *pkt, const void *src, size_t len); | - | ||||||||||||
647 | - | |||||||||||||
648 | - | |||||||||||||
649 | int WPACKET_memset(WPACKET *pkt, int ch, size_t len); | - | ||||||||||||
650 | - | |||||||||||||
651 | - | |||||||||||||
652 | - | |||||||||||||
653 | - | |||||||||||||
654 | - | |||||||||||||
655 | - | |||||||||||||
656 | int WPACKET_sub_memcpy__(WPACKET *pkt, const void *src, size_t len, | - | ||||||||||||
657 | size_t lenbytes); | - | ||||||||||||
658 | int WPACKET_get_total_written(WPACKET *pkt, size_t *written); | - | ||||||||||||
659 | - | |||||||||||||
660 | - | |||||||||||||
661 | - | |||||||||||||
662 | - | |||||||||||||
663 | - | |||||||||||||
664 | int WPACKET_get_length(WPACKET *pkt, size_t *len); | - | ||||||||||||
665 | - | |||||||||||||
666 | - | |||||||||||||
667 | - | |||||||||||||
668 | - | |||||||||||||
669 | - | |||||||||||||
670 | unsigned char *WPACKET_get_curr(WPACKET *pkt); | - | ||||||||||||
671 | - | |||||||||||||
672 | - | |||||||||||||
673 | void WPACKET_cleanup(WPACKET *pkt); | - | ||||||||||||
Switch to Source code | Preprocessed file |