diff options
author | Ivan Nardi <12729895+IvanNardi@users.noreply.github.com> | 2024-07-12 14:22:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-12 14:22:25 +0200 |
commit | c3ba65311e2cf4aba8b51cdb6800a5654ef1d060 (patch) | |
tree | 7f0aa30fc4ab1d0aaec75f08b84cb7f3705d29fa /src/lib/protocols/collectd.c | |
parent | 456f0fd4279ae727831a80c506a343b8a9aedd90 (diff) |
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)
Diffstat (limited to 'src/lib/protocols/collectd.c')
-rw-r--r-- | src/lib/protocols/collectd.c | 15 |
1 files changed, 6 insertions, 9 deletions
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); } |