/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 | 3.90k | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { |
15 | 3.90k | u_int16_t app_proto; /* unused */ |
16 | 3.90k | struct ndpi_packet_struct *packet; |
17 | 3.90k | ndpi_protocol_category_t category; |
18 | | |
19 | 3.90k | if (ndpi_struct == NULL) { |
20 | 2 | fuzz_init_detection_module(&ndpi_struct, NULL); |
21 | 2 | } |
22 | | |
23 | 3.90k | packet = &ndpi_struct->packet; |
24 | 3.90k | packet->payload = data; |
25 | 3.90k | packet->payload_packet_len = size; |
26 | 3.90k | #ifndef STUN_TCP |
27 | 3.90k | packet->udp = &udph; |
28 | | #else |
29 | | packet->tcp = &tcph; |
30 | | #endif |
31 | 3.90k | packet->iph = &iph; /* IPv4 only */ |
32 | | |
33 | 3.90k | is_stun(ndpi_struct, &ndpi_flow, &app_proto, &category); |
34 | 3.90k | return 0; |
35 | 3.90k | } |