From 262c526c4efcbea0148bfade1fb0abfeea674aea Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 1 Oct 2024 11:51:24 -0700 Subject: [PATCH] net/portmapper: don't treat 0.0.0.0 as a valid IP Updates tailscale/corp#23538 Change-Id: I58b8c30abe43f1d1829f01eb9fb2c1e6e8db9476 Signed-off-by: Brad Fitzpatrick --- net/portmapper/portmapper.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/portmapper/portmapper.go b/net/portmapper/portmapper.go index 7cdca1fb3..71b55b8a7 100644 --- a/net/portmapper/portmapper.go +++ b/net/portmapper/portmapper.go @@ -781,6 +781,10 @@ func parsePMPResponse(pkt []byte) (res pmpResponse, ok bool) { return res, false } res.PublicAddr = netaddr.IPv4(pkt[8], pkt[9], pkt[10], pkt[11]) + if res.PublicAddr.IsUnspecified() { + // Zero it out so it's not Valid and used accidentally elsewhere. + res.PublicAddr = netip.Addr{} + } } return res, true