fuzzing: improve coverage (#2495)

Fix detection of WebDAV and Gnutella (over HTTP)
Fix detection of z3950

Add two fuzzers to test `ndpi_memmem()` and `ndpi_strnstr()`

Remove some dead code:
* RTP: the same exact check is performed at the very beginning of the
function
* MQTT: use a better helper to exclude the protocol
* Colletd: `ndpi_hostname_sni_set()` never fails

Update pl7m code (fix a Use-of-uninitialized-value error)
This commit is contained in:
Ivan Nardi 2024-07-12 14:22:25 +02:00 committed by GitHub
parent 456f0fd427
commit c3ba65311e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 142 additions and 63 deletions

View file

@ -30,7 +30,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
for (i = 0; i < num_iteration; i++) {
value = fuzzed_data.ConsumeBytesAsString(fuzzed_data.ConsumeIntegral<u_int8_t>());
class_id = fuzzed_data.ConsumeIntegral<u_int16_t>();
rc = ndpi_domain_classify_add(ndpi_struct, d, class_id, (char*)value.c_str());
rc = ndpi_domain_classify_add(fuzzed_data.ConsumeBool() ? ndpi_struct : NULL,
d, class_id, (char*)value.c_str());
/* Keep one random entry really added */
if (rc == true && is_added == 0 && fuzzed_data.ConsumeBool()) {