diff options
author | Tamir Duberstein <tamird@google.com> | 2018-09-12 09:37:57 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-09-12 09:39:01 -0700 |
commit | cbf39804647eabafb6138714ed222dbdc4781f2e (patch) | |
tree | aee396f3870f863d2edb72cf125fe83d08255d8e /pkg/tcpip/header | |
parent | b4aed01bf227bfc0b29ce3100858366f60c0647b (diff) |
Prevent UDP sockets from binding to bound ports
PiperOrigin-RevId: 212653818
Change-Id: Ib4e1d754d9cdddeaa428a066cb675e6ec44d91ad
Diffstat (limited to 'pkg/tcpip/header')
-rw-r--r-- | pkg/tcpip/header/ipv6.go | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/pkg/tcpip/header/ipv6.go b/pkg/tcpip/header/ipv6.go index 58ebc3b06..62bc23c27 100644 --- a/pkg/tcpip/header/ipv6.go +++ b/pkg/tcpip/header/ipv6.go @@ -16,6 +16,7 @@ package header import ( "encoding/binary" + "strings" "gvisor.googlesource.com/gvisor/pkg/tcpip" ) @@ -190,12 +191,5 @@ func IsV4MappedAddress(addr tcpip.Address) bool { return false } - const prefix = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff" - for i := 0; i < len(prefix); i++ { - if prefix[i] != addr[i] { - return false - } - } - - return true + return strings.HasPrefix(string(addr), "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff") } |