From d1f8d01d4b8dd83085918cc95c7eafa57a85425f Mon Sep 17 00:00:00 2001 From: William Robinet Date: Wed, 20 Jan 2021 11:22:55 +0100 Subject: [PATCH] Check packet size before looking at IP header --- base/network.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/base/network.c b/base/network.c index 766c169..fbbbbf0 100644 --- a/base/network.c +++ b/base/network.c @@ -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);