diff options
author | Michele Campus <fci1908@gmail.com> | 2016-08-11 09:16:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-11 09:16:42 +0200 |
commit | 0e0406895294dc9ed3bcee50609bcfd5c9e9c5f0 (patch) | |
tree | 6e42eef17418d4e605542a54bb4d7660745d48d9 /src | |
parent | 8bccfa5b10c4bb67e4378b26b3b3acbc28560c67 (diff) | |
parent | 0a06b3b208279606775eaced6894c13c8cee4b7a (diff) |
Merge pull request #242 from theirix/fix-drda
Fixed DRDA detection
Diffstat (limited to 'src')
-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; |