From 4d01eeb4dde4f4f9e212f364b785a695726eb2e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandor=20Sz=C3=BCcs?= Date: Sun, 14 Jan 2024 12:29:59 +0100 Subject: [PATCH] fix: 2852 unspecified addresses should fail MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sandor Szücs --- net/net.go | 2 ++ net/net_test.go | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/net/net.go b/net/net.go index 2e1e7990f9..d957032010 100644 --- a/net/net.go +++ b/net/net.go @@ -144,6 +144,8 @@ func ParseIPCIDRs(cidrs []string) (*netipx.IPSet, error) { } else if addr, err := netip.ParseAddr(w); err != nil { return nil, err + } else if addr.IsUnspecified() { + return nil, fmt.Errorf("failed to parse cidr: addr is unspcified: %s", w) } else { b.Add(addr) } diff --git a/net/net_test.go b/net/net_test.go index 1f2412ac38..6f05d11420 100644 --- a/net/net_test.go +++ b/net/net_test.go @@ -179,6 +179,10 @@ func TestParseIPCIDRs(t *testing.T) { input []string wantErr bool }{ + {[]string{"::"}, true}, + {[]string{"f::"}, false}, + {[]string{"::1"}, false}, + {[]string{"::1/8"}, false}, {[]string{"1.2.3.4.5"}, true}, {[]string{"1.2.3.4/"}, true}, {[]string{"1.2.3.4/245"}, true},