Coverage Report

Created: 2026-02-21 07:19

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/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
static char *path = NULL;
15
16
36
int LLVMFuzzerInitialize(int *argc, char ***argv) {
17
36
  (void)argc;
18
19
36
  path = dirname(strdup(*argv[0])); /* No errors; no free! */
20
36
  return 0;
21
36
}
22
23
24.7k
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
24
24.7k
  u_int16_t app_proto; /* unused */
25
24.7k
  struct ndpi_packet_struct *packet;
26
24.7k
  ndpi_protocol_category_t category;
27
28
24.7k
  if (ndpi_struct == NULL) {
29
4
    fuzz_init_detection_module(&ndpi_struct, NULL, path);
30
4
  }
31
32
24.7k
  packet = &ndpi_struct->packet;
33
24.7k
  packet->payload = data;
34
24.7k
  packet->payload_packet_len = size;
35
24.7k
#ifndef STUN_TCP
36
24.7k
  packet->udp = &udph;
37
#else
38
  packet->tcp = &tcph;
39
#endif
40
24.7k
  packet->iph = &iph; /* IPv4 only */
41
42
24.7k
  is_stun(ndpi_struct, &ndpi_flow, &app_proto, &category);
43
24.7k
  return 0;
44
24.7k
}