summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/header/parse/parse.go
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2021-05-13 21:00:53 +0000
committergVisor bot <gvisor-bot@google.com>2021-05-13 21:00:53 +0000
commite1cfd3185c285f4dc69804210cc0d77ec582beb5 (patch)
tree866c789fcc0f67ec0933e3cf88fed6628e85b6f6 /pkg/tcpip/header/parse/parse.go
parentf4d9f967005fdf7995439f56839cbb4a7589ff6c (diff)
parent84f04cc858644e9748a82f33b834a84c8b0fc934 (diff)
Merge release-20210510.0-27-g84f04cc85 (automated)
Diffstat (limited to 'pkg/tcpip/header/parse/parse.go')
-rw-r--r--pkg/tcpip/header/parse/parse.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/pkg/tcpip/header/parse/parse.go b/pkg/tcpip/header/parse/parse.go
index ebb4b2c1d..1c913b5e1 100644
--- a/pkg/tcpip/header/parse/parse.go
+++ b/pkg/tcpip/header/parse/parse.go
@@ -60,9 +60,13 @@ func IPv4(pkt *stack.PacketBuffer) bool {
return false
}
ipHdr = header.IPv4(hdr)
+ length := int(ipHdr.TotalLength()) - len(hdr)
+ if length < 0 {
+ return false
+ }
pkt.NetworkProtocolNumber = header.IPv4ProtocolNumber
- pkt.Data().CapLength(int(ipHdr.TotalLength()) - len(hdr))
+ pkt.Data().CapLength(length)
return true
}