From eb7aa112c36fc8cb5a404cd37fef6c8d5252313a Mon Sep 17 00:00:00 2001 From: aouinizied Date: Fri, 10 Jul 2020 14:32:15 +0200 Subject: [PATCH] Add missing length check. --- nfstream/observer_cc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nfstream/observer_cc.c b/nfstream/observer_cc.c index 003f44d..fef0139 100644 --- a/nfstream/observer_cc.c +++ b/nfstream/observer_cc.c @@ -905,7 +905,7 @@ int process_packet(pcap_t * pcap_handle, const struct pcap_pkthdr *header, const mpls.u32 = ntohl(mpls.u32); type = ETH_P_IP, ip_offset += 4; - while(!mpls.mpls.s) { + while(!mpls.mpls.s && (((bpf_u_int32)ip_offset) + 4 < header->caplen)) { mpls.u32 = *((uint32_t *) &packet[ip_offset]); mpls.u32 = ntohl(mpls.u32); ip_offset += 4;