/src/ndpi/fuzz/fuzz_is_stun.c
Line | Count | Source |
1 | | #include "ndpi_api.h" |
2 | | #include "ndpi_private.h" |
3 | | #include "fuzz_common_code.h" |
4 | | |
5 | | static struct ndpi_detection_module_struct *ndpi_struct = NULL; |
6 | | static struct ndpi_flow_struct ndpi_flow; |
7 | | struct ndpi_iphdr iph; |
8 | | #ifdef STUN_TCP |
9 | | struct ndpi_tcphdr tcph; |
10 | | #else |
11 | | struct ndpi_udphdr udph; |
12 | | #endif |
13 | | |
14 | | extern int is_stun(struct ndpi_detection_module_struct *ndpi_struct, |
15 | | struct ndpi_flow_struct *flow, |
16 | | u_int16_t *app_proto); |
17 | | |
18 | | |
19 | 3.87k | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
20 | 3.87k | u_int16_t app_proto; /* unused */ |
21 | 3.87k | struct ndpi_packet_struct *packet; |
22 | | |
23 | 3.87k | if (ndpi_struct == NULL) { |
24 | 2 | fuzz_init_detection_module(&ndpi_struct, NULL); |
25 | 2 | } |
26 | | |
27 | 3.87k | packet = &ndpi_struct->packet; |
28 | 3.87k | packet->payload = data; |
29 | 3.87k | packet->payload_packet_len = size; |
30 | 3.87k | #ifndef STUN_TCP |
31 | 3.87k | packet->udp = &udph; |
32 | | #else |
33 | | packet->tcp = &tcph; |
34 | | #endif |
35 | 3.87k | packet->iph = &iph; /* IPv4 only */ |
36 | | |
37 | 3.87k | is_stun(ndpi_struct, &ndpi_flow, &app_proto); |
38 | 3.87k | return 0; |
39 | 3.87k | } |