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