Merge pull request #205 from theirix/dns-overflow
Fixed dns buffer overflow
This commit is contained in:
@@ -112,10 +112,8 @@ void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct nd
|
|||||||
ret_code = (is_query == 0) ? 0 : (dns_header.flags & 0x0F);
|
ret_code = (is_query == 0) ? 0 : (dns_header.flags & 0x0F);
|
||||||
int j = 0;
|
int j = 0;
|
||||||
int off = sizeof(struct ndpi_dns_packet_header) + 1;
|
int off = sizeof(struct ndpi_dns_packet_header) + 1;
|
||||||
while((flow->packet.payload[off] != '\0'))
|
while(flow->packet.payload[off] != '\0' && off < flow->packet.payload_packet_len)
|
||||||
{
|
{
|
||||||
if(off < flow->packet.payload_packet_len)
|
|
||||||
{
|
|
||||||
flow->host_server_name[j] = flow->packet.payload[off];
|
flow->host_server_name[j] = flow->packet.payload[off];
|
||||||
if(j < strlen((char*)flow->host_server_name)) {
|
if(j < strlen((char*)flow->host_server_name)) {
|
||||||
if(flow->host_server_name[j] < ' ')
|
if(flow->host_server_name[j] < ' ')
|
||||||
@@ -123,7 +121,6 @@ void ndpi_search_dns(struct ndpi_detection_module_struct *ndpi_struct, struct nd
|
|||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
off++;
|
off++;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
flow->host_server_name[j] = '\0';
|
flow->host_server_name[j] = '\0';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user