From c3ba65311e2cf4aba8b51cdb6800a5654ef1d060 Mon Sep 17 00:00:00 2001 From: Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> Date: Fri, 12 Jul 2024 14:22:25 +0200 Subject: 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) --- src/lib/protocols/collectd.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/lib/protocols/collectd.c') diff --git a/src/lib/protocols/collectd.c b/src/lib/protocols/collectd.c index 4e37a0768..3c878e9c9 100644 --- a/src/lib/protocols/collectd.c +++ b/src/lib/protocols/collectd.c @@ -101,11 +101,11 @@ static int ndpi_int_collectd_check_type(u_int16_t block_type) return 1; } -static int ndpi_int_collectd_dissect_hostname(struct ndpi_flow_struct * const flow, - struct ndpi_packet_struct const * const packet, - u_int16_t block_length) +static void ndpi_int_collectd_dissect_hostname(struct ndpi_flow_struct * const flow, + struct ndpi_packet_struct const * const packet, + u_int16_t block_length) { - return (ndpi_hostname_sni_set(flow, &packet->payload[4], block_length, NDPI_HOSTNAME_NORM_ALL) == NULL); + ndpi_hostname_sni_set(flow, &packet->payload[4], block_length, NDPI_HOSTNAME_NORM_ALL); } static int ndpi_int_collectd_dissect_username(struct ndpi_flow_struct * const flow, @@ -184,11 +184,8 @@ static void ndpi_search_collectd(struct ndpi_detection_module_struct *ndpi_struc return; } - if (hostname_length > 0 && - ndpi_int_collectd_dissect_hostname(flow, packet, hostname_length) != 0) - { - ndpi_set_risk(flow, NDPI_MALFORMED_PACKET, "Invalid collectd Header"); - } + if (hostname_length > 0) + ndpi_int_collectd_dissect_hostname(flow, packet, hostname_length); ndpi_int_collectd_add_connection(ndpi_struct, flow); } -- cgit v1.2.3