Skip to content

Commit

Permalink
fix: 2852 unspecified addresses should fail
Browse files Browse the repository at this point in the history
Signed-off-by: Sandor Szücs <[email protected]>
  • Loading branch information
szuecs committed Jan 14, 2024
1 parent 14cec82 commit 4d01eeb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 4 additions & 0 deletions net/net_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down

0 comments on commit 4d01eeb

Please sign in to comment.