diff options
author | Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> | 2025-06-23 11:24:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-06-23 11:24:18 +0200 |
commit | 978ca1ba1ab0f9d3f7d3c46e6f80a829b08205db (patch) | |
tree | f7748c2d810c75c0155fa3f81e3146a797f6fdba /fuzz/fuzz_readerutils_workflow.cpp | |
parent | 6cbc8d1471be221766fac49ed73f5b0e837917be (diff) |
New API to enable/disable protocols. Removed `NDPI_LAST_IMPLEMENTED_PROTOCOL` (#2894)
Change the API to enable/disable protocols: you can set that via the
standard `ndpi_set_config()` function, as every configuration
parameters. By default, all protocols are enabled.
Split the (local) context initialization into two phases:
* `ndpi_init_detection_module()`: generic part. It does not depend on the
configuration and on the protocols being enabled or not. It also
calculates the real number of internal protocols
* `ndpi_finalize_initialization()`: apply the configuration. All the
initialization stuff that depend on protocols being enabled or not
must be put here
This is the last step to have the protocols number fully calculated at
runtime
Remove a (now) useless fuzzer.
Important API changes:
* remove `NDPI_LAST_IMPLEMENTED_PROTOCOL` define
* remove `ndpi_get_num_internal_protocols()`. To get the number of
configured protocols (internal and custom) you must use
`ndpi_get_num_protocols()` after having called `ndpi_finalize_initialization()`
Diffstat (limited to 'fuzz/fuzz_readerutils_workflow.cpp')
-rw-r--r-- | fuzz/fuzz_readerutils_workflow.cpp | 23 |
1 files changed, 1 insertions, 22 deletions
diff --git a/fuzz/fuzz_readerutils_workflow.cpp b/fuzz/fuzz_readerutils_workflow.cpp index 3b60c8967..67dea7d45 100644 --- a/fuzz/fuzz_readerutils_workflow.cpp +++ b/fuzz/fuzz_readerutils_workflow.cpp @@ -33,17 +33,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { int r; char errbuf[PCAP_ERRBUF_SIZE]; FILE *fd; - u_int8_t debug_protos_index; - char *_debug_protocols; - const char *strs[] = { "all", - "dns,quic", - "+dns:-quic", - "all;-http", - "foo", - "openvpn", - "+bar;-foo", - NULL, - "http;bar" }; /* Data structure: 8 bytes header for random values + pcap file */ @@ -63,36 +52,28 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { serialization_format = static_cast<ndpi_serialization_format>(fuzzed_data.ConsumeIntegralInRange(1, 4)); - debug_protos_index = fuzzed_data.ConsumeIntegralInRange(0, static_cast<int>(sizeof(strs) / sizeof(char *) - 1)); - _debug_protocols = ndpi_strdup(strs[debug_protos_index]); - /* byte8 is still unused */ enable_doh_dot_detection = 1; fd = buffer_to_file(data + 8, size - 8); if(fd == NULL) { - ndpi_free(_debug_protocols); return 0; } pcap_handle = pcap_fopen_offline(fd, errbuf); if(pcap_handle == NULL) { fclose(fd); - ndpi_free(_debug_protocols); return 0; } if(ndpi_is_datalink_supported(pcap_datalink(pcap_handle)) == 0) { pcap_close(pcap_handle); - ndpi_free(_debug_protocols); return 0; } g_ctx = ndpi_global_init(); - - - w = ndpi_workflow_init(&prefs, pcap_handle, 1, serialization_format, g_ctx, NULL); + w = ndpi_workflow_init(&prefs, pcap_handle, 1, serialization_format, g_ctx); if(w) { ndpi_finalize_initialization(w->ndpi_struct); @@ -109,7 +90,5 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { ndpi_global_deinit(g_ctx); - ndpi_free(_debug_protocols); - return 0; } |