From 17bab652afebdc43d77969431b9147cca039f61e Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Fri, 12 Jul 2019 16:17:18 -0700 Subject: [PATCH] Check that IP headers contain correct version PiperOrigin-RevId: 257888338 --- pkg/tcpip/header/ipv4.go | 4 ++++ pkg/tcpip/header/ipv6.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/pkg/tcpip/header/ipv4.go b/pkg/tcpip/header/ipv4.go index 7b8034de4..94a3af289 100644 --- a/pkg/tcpip/header/ipv4.go +++ b/pkg/tcpip/header/ipv4.go @@ -272,6 +272,10 @@ func (b IPv4) IsValid(pktSize int) bool { return false } + if IPVersion(b) != IPv4Version { + return false + } + return true } diff --git a/pkg/tcpip/header/ipv6.go b/pkg/tcpip/header/ipv6.go index 7163eaa36..95fe8bfc3 100644 --- a/pkg/tcpip/header/ipv6.go +++ b/pkg/tcpip/header/ipv6.go @@ -184,6 +184,10 @@ func (b IPv6) IsValid(pktSize int) bool { return false } + if IPVersion(b) != IPv6Version { + return false + } + return true }