From 33bdcabf03c16695c7159545437d75e7d591ea6c Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 20 Mar 2020 13:37:45 -0700 Subject: [PATCH] wgengine/magicsock: call stun callback w/ only valid part of STUN packet --- wgengine/magicsock/magicsock.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wgengine/magicsock/magicsock.go b/wgengine/magicsock/magicsock.go index 7d0de925b..52af63b02 100644 --- a/wgengine/magicsock/magicsock.go +++ b/wgengine/magicsock/magicsock.go @@ -894,7 +894,7 @@ func (c *Conn) awaitUDP4(b []byte) { } addr := pAddr.(*net.UDPAddr) if stun.Is(b[:n]) { - c.stunReceiveFunc.Load().(func([]byte, *net.UDPAddr))(b, addr) + c.stunReceiveFunc.Load().(func([]byte, *net.UDPAddr))(b[:n], addr) continue } @@ -1002,7 +1002,7 @@ func (c *Conn) ReceiveIPv6(b []byte) (int, conn.Endpoint, *net.UDPAddr, error) { } addr := pAddr.(*net.UDPAddr) if stun.Is(b[:n]) { - c.stunReceiveFunc.Load().(func([]byte, *net.UDPAddr))(b, addr) + c.stunReceiveFunc.Load().(func([]byte, *net.UDPAddr))(b[:n], addr) continue } // TODO(bradfitz): finish. look up addrset, return etc.