diff --git a/src/scan.c b/src/scan.c index fa3ec2a..c4aabe7 100644 --- a/src/scan.c +++ b/src/scan.c @@ -26,12 +26,12 @@ static void dispatch_callback(u_char *user, const struct pcap_pkthdr *h, sizeof(struct tcphdr)) { tcp_response(packet, data); } - if (iphdr->protocol == IPPROTO_UDP && + else if (iphdr->protocol == IPPROTO_UDP && h->caplen >= sizeof(struct ether_header) + sizeof(struct iphdr) + sizeof(struct udphdr)) { udp_response(packet, data); } - if (iphdr->protocol == IPPROTO_ICMP && + else if (iphdr->protocol == IPPROTO_ICMP && h->caplen >= sizeof(struct ether_header) + sizeof(struct iphdr) + sizeof(struct icmphdr)) { icmp_response(packet, data);