diff options
author | theirix <theirix@gmail.com> | 2016-08-11 01:51:32 +0300 |
---|---|---|
committer | theirix <theirix@gmail.com> | 2016-08-11 01:55:24 +0300 |
commit | 0a06b3b208279606775eaced6894c13c8cee4b7a (patch) | |
tree | 6e42eef17418d4e605542a54bb4d7660745d48d9 /src/lib/protocols/drda.c | |
parent | 8bccfa5b10c4bb67e4378b26b3b3acbc28560c67 (diff) |
Fixed DRDA detection
Diffstat (limited to 'src/lib/protocols/drda.c')
-rw-r--r-- | src/lib/protocols/drda.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/lib/protocols/drda.c b/src/lib/protocols/drda.c index 9240e8364..9369665db 100644 --- a/src/lib/protocols/drda.c +++ b/src/lib/protocols/drda.c @@ -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; |