Skip to content

Commit

Permalink
fuzz: improve fuzzing coverage
Browse files Browse the repository at this point in the history
Updtae pl7m code (Fix swap-direction mutation)
  • Loading branch information
IvanNardi committed Dec 11, 2024
1 parent 8034105 commit 5133b0d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions fuzz/fuzz_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,16 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
snprintf(cfg_value, sizeof(cfg_value), "%d", value);
ndpi_set_config(ndpi_info_mod, NULL, "dpi.guess_ip_before_port", cfg_value);
}
if(fuzzed_data.ConsumeBool()) {
value = fuzzed_data.ConsumeIntegralInRange(0, 1 + 1);
snprintf(cfg_value, sizeof(cfg_value), "%d", value);
ndpi_set_config(ndpi_info_mod, NULL, "dpi.compute_entropy", cfg_value);
}
if(fuzzed_data.ConsumeBool()) {
value = fuzzed_data.ConsumeIntegralInRange(0, 16777215 + 1);
snprintf(cfg_value, sizeof(cfg_value), "%d", value);
ndpi_set_config(ndpi_info_mod, NULL, "dpi.address_cache_size", cfg_value);
}
if(fuzzed_data.ConsumeBool()) {
value = fuzzed_data.ConsumeIntegralInRange(0, 1 + 1);
snprintf(cfg_value, sizeof(cfg_value), "%d", value);
Expand Down
1 change: 1 addition & 0 deletions fuzz/fuzz_ndpi_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
ndpi_set_config(workflow->ndpi_struct, "tls", "dpi.heuristics", "0x07");
ndpi_set_config(workflow->ndpi_struct, "tls", "dpi.heuristics.max_packets_extra_dissection", "40");
ndpi_set_config(workflow->ndpi_struct, "stun", "monitoring", "1");
ndpi_set_config(workflow->ndpi_struct, NULL, "dpi.address_cache_size", "8192");

ndpi_finalize_initialization(workflow->ndpi_struct);

Expand Down
2 changes: 1 addition & 1 deletion src/lib/third_party/src/fuzz/pl7m.c
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ static void swap_direction(struct m_pkt *p)
case IPPROTO_UDP:
udp_h = (struct udphdr *)(p->raw_data + p->l4_offset);
tmp_port = udp_h->source;
udp_h->source = udp_h->source;
udp_h->source = udp_h->dest;
udp_h->dest = tmp_port;
break;
case IPPROTO_TCP:
Expand Down

0 comments on commit 5133b0d

Please sign in to comment.