From: bert hubert Date: Fri, 6 Nov 2015 15:04:26 +0000 (+0100) Subject: don't confuse dnspcap users with incomplete packets X-Git-Tag: dnsdist-1.0.0-alpha1~239^2~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=66afeb443b071792fd3979f7266c3bae09472e0b;p=pdns don't confuse dnspcap users with incomplete packets --- diff --git a/pdns/dnspcap.cc b/pdns/dnspcap.cc index 5ca85d5ce..0280d702f 100644 --- a/pdns/dnspcap.cc +++ b/pdns/dnspcap.cc @@ -97,6 +97,10 @@ try d_udp=reinterpret_cast(d_buffer + d_skipMediaHeader + 4 * d_ip->ip_hl); d_payload = (unsigned char*)d_udp + sizeof(struct udphdr); d_len = ntohs(d_udp->uh_ulen) - sizeof(struct udphdr); + if((const char*)d_payload + d_len > d_buffer + d_pheader.caplen) { + d_runts++; + continue; + } d_correctpackets++; return true; } @@ -104,6 +108,11 @@ try d_udp=reinterpret_cast(d_buffer + d_skipMediaHeader + sizeof(struct ip6_hdr)); d_payload = (unsigned char*)d_udp + sizeof(struct udphdr); d_len = ntohs(d_udp->uh_ulen) - sizeof(struct udphdr); + if((const char*)d_payload + d_len > d_buffer + d_pheader.caplen) { + d_runts++; + continue; + } + d_correctpackets++; return true; }