diff --git a/src/lib/protocols/softether.c b/src/lib/protocols/softether.c index 6afdebb4abd..377d9ed3aad 100644 --- a/src/lib/protocols/softether.c +++ b/src/lib/protocols/softether.c @@ -104,6 +104,10 @@ static size_t dissect_softether_type(enum softether_value_type t, } if (t == VALUE_DATA) { + if (siz == 0) + { + return 0; + } siz--; } v->value_size = siz; @@ -288,11 +292,6 @@ static int dissect_softether_ip_port(struct ndpi_flow_struct *flow, return 1; } - if (ip_port_separator < (char const *)packet->payload + NDPI_STATICSTRING_LEN("IP=")) - { - return 1; - } - ip_len = ndpi_min(sizeof(flow->protos.softether.ip) - 1, ip_port_separator - (char const *)packet->payload - NDPI_STATICSTRING_LEN("IP=")); @@ -300,15 +299,15 @@ static int dissect_softether_ip_port(struct ndpi_flow_struct *flow, ip_len); flow->protos.softether.ip[ip_len] = '\0'; - if (ip_port_separator < (char const *)packet->payload + - NDPI_STATICSTRING_LEN("IP=") + NDPI_STATICSTRING_LEN(",PORT=")) + if (packet->payload_packet_len < (ip_port_separator - (char const *)packet->payload) + + NDPI_STATICSTRING_LEN(",PORT=")) { return 1; } port_len = ndpi_min(sizeof(flow->protos.softether.port) - 1, - ip_port_separator - (char const *)packet->payload - - NDPI_STATICSTRING_LEN("IP=") - NDPI_STATICSTRING_LEN(",PORT=")); + packet->payload_packet_len - (ip_port_separator - (char const *)packet->payload) - + NDPI_STATICSTRING_LEN(",PORT=")); strncpy(flow->protos.softether.port, ip_port_separator + NDPI_STATICSTRING_LEN(",PORT="), port_len); flow->protos.softether.port[port_len] = '\0';