diff options
author | 2021-06-04 04:17:17 -0400 | |
---|---|---|
committer | 2021-06-04 10:17:17 +0200 | |
commit | 846ace3f51e2cbcc747047819215aeaeaed6bee7 (patch) | |
tree | bfc97bf96c010641d166ee058047e793127431f4 /plugin/normalize.go | |
parent | a50c0f151fd59d0c0261045e1b8c1dd8deffff5e (diff) | |
download | coredns-846ace3f51e2cbcc747047819215aeaeaed6bee7.tar.gz coredns-846ace3f51e2cbcc747047819215aeaeaed6bee7.tar.zst coredns-846ace3f51e2cbcc747047819215aeaeaed6bee7.zip |
Fix IPv6 case for CIDR format reverse zones (#4652)
* fix ipv6 case for cidr.Class
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
* add check and test case for invalid ipv6 cidr
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
* net package is bad at detecting ipv6/ipv4
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
* rename Class -> Split
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
Diffstat (limited to 'plugin/normalize.go')
-rw-r--r-- | plugin/normalize.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/plugin/normalize.go b/plugin/normalize.go index b46966b74..7543e42a0 100644 --- a/plugin/normalize.go +++ b/plugin/normalize.go @@ -163,8 +163,12 @@ func SplitHostPort(s string) (hosts []string, port string, err error) { return []string{s}, port, nil } + if s[0] == ':' || (s[0] == '0' && strings.Contains(s, ":")) { + return nil, "", fmt.Errorf("invalid CIDR %s", s) + } + // now check if multiple hosts must be returned. - nets := cidr.Class(n) + nets := cidr.Split(n) hosts = cidr.Reverse(nets) return hosts, port, nil } |