Check packet size before looking at IP header

This commit is contained in:
William Robinet 2021-01-20 11:22:55 +01:00
parent 10963dd981
commit d1f8d01d4b

View file

@ -126,6 +126,12 @@ int network_process_packet(handler,timestamp,data,length)
p.len=length;
p.ip=(struct ip *)data;
if(p.len < 20) {
if(!(NET_print_flags & NET_PRINT_JSON))
printf("Malformed packet, packet too small to contain IP header, skipping ...\n");
return(0);
}
/*Handle, or rather mishandle, fragmentation*/
off=ntohs(p.ip->ip_off);