Merge pull request #242 from theirix/fix-drda

Fixed DRDA detection
This commit is contained in:
Michele Campus
2016-08-11 09:16:42 +02:00
committed by GitHub
+6 -6
View File
@@ -44,14 +44,15 @@ void ndpi_search_drda(struct ndpi_detection_module_struct *ndpi_struct,
/* check port */
if((ntohs(packet->tcp->source) == DRDA_PORT ||
ntohs(packet->tcp->dest) == DRDA_PORT)) {
ntohs(packet->tcp->dest) == DRDA_PORT) &&
payload_len >= sizeof(struct ndpi_drda_hdr)) {
struct ndpi_drda_hdr * drda = (struct ndpi_drda_hdr *) packet->payload;
u_int16_t len = ntohs(drda->length);
/* check first header */
if(len - 6 != ntohs(drda->length2) &&
if(len != ntohs(drda->length2) + 6 &&
drda->magic != 0xd0)
goto no_drda;
@@ -59,15 +60,14 @@ void ndpi_search_drda(struct ndpi_detection_module_struct *ndpi_struct,
if(payload_len > len) {
count = len;
const u_int8_t * pp = packet->payload + len;
while(count < payload_len)
while(count + sizeof(struct ndpi_drda_hdr) < payload_len)
{
/* update info */
drda = (struct ndpi_drda_hdr *) pp;
drda = (struct ndpi_drda_hdr *)(packet->payload + count);
len = ntohs(drda->length);
if(len - 6 != ntohs(drda->length2) &&
if(len != ntohs(drda->length2) + 6 &&
drda->magic != 0xd0)
goto no_drda;