aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCampus <campus@ntop.org>2016-03-29 15:04:15 +0200
committerCampus <campus@ntop.org>2016-03-29 15:04:15 +0200
commit8dacc91d5167e34f5ce741cccf6d42e7e95d8277 (patch)
tree64565a64f724e1abe102500465b4ca95885be766 /src
parenta59427398921b234bf152cc8f938f83fca07ee2b (diff)
fixed dns check host name server
Diffstat (limited to 'src')
-rw-r--r--src/lib/ndpi_main.c1
-rw-r--r--src/lib/protocols/dns.c16
2 files changed, 12 insertions, 5 deletions
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index 287162a7c..af5bbdbe4 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -3083,6 +3083,7 @@ void check_ndpi_tcp_flow_func(struct ndpi_detection_module_struct *ndpi_struct,
detection_bitmask) != 0) {
ndpi_struct->callback_buffer_tcp_payload[a].func(ndpi_struct, flow);
+
if(flow->detected_protocol_stack[0] != NDPI_PROTOCOL_UNKNOWN)
break; /* Stop after detecting the first protocol */
}
diff --git a/src/lib/protocols/dns.c b/src/lib/protocols/dns.c
index c975465ea..3be9c888b 100644
--- a/src/lib/protocols/dns.c
+++ b/src/lib/protocols/dns.c
@@ -114,11 +114,17 @@ void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct nd
int off = sizeof(struct ndpi_dns_packet_header) + 1;
while((flow->packet.payload[off] != '\0'))
{
- flow->host_server_name[j] = flow->packet.payload[off];
- if(flow->host_server_name[j] < ' ')
- flow->host_server_name[j] = '.';
- off++;
- j++;
+ if(off < flow->packet.payload_packet_len)
+ {
+ flow->host_server_name[j] = flow->packet.payload[off];
+ if(j < strlen(flow->host_server_name))
+ {
+ if(flow->host_server_name[j] < ' ')
+ flow->host_server_name[j] = '.';
+ off++;
+ j++;
+ }
+ }
}
flow->host_server_name[j] = '\0';