Replace complicated TPKT header validation with an helper function (#2201)

* Replace complicated TPKT header validation with an helper function

* Move tpkt_verify_hdr function definition to ndpi_utils.c
This commit is contained in:
Vladimir Gavrilov
2023-12-10 12:10:50 +01:00
committed by GitHub
parent f74cf16c36
commit c809e7c069
6 changed files with 35 additions and 45 deletions
+2 -4
View File
@@ -41,15 +41,13 @@ static void ndpi_int_rdp_add_connection(struct ndpi_detection_module_struct *ndp
static void ndpi_search_rdp(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow) {
struct ndpi_packet_struct *packet = &ndpi_struct->packet;
const struct ndpi_packet_struct * const packet = &ndpi_struct->packet;
NDPI_LOG_DBG(ndpi_struct, "search RDP\n");
if (packet->tcp != NULL) {
if(packet->payload_packet_len > 13 &&
/* TPKT */
packet->payload[0] == 0x03 && packet->payload[1] == 0x00 &&
ntohs(*(uint16_t *)&packet->payload[2]) == packet->payload_packet_len &&
tpkt_verify_hdr(packet) &&
/* COTP */
packet->payload[4] == packet->payload_packet_len - 5) {