aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris O'Haver <cohaver@infoblox.com> 2022-02-17 15:13:18 -0500
committerGravatar GitHub <noreply@github.com> 2022-02-17 15:13:18 -0500
commitf8a02aaf58f26ae1791092ca37ac469c74c41172 (patch)
treed8019dd72db6f8001c5da2eb95be7e13e61aa493
parent5bb8947309eeb3b677c5a3eecc920fdfe6addd6e (diff)
downloadcoredns-f8a02aaf58f26ae1791092ca37ac469c74c41172.tar.gz
coredns-f8a02aaf58f26ae1791092ca37ac469c74c41172.tar.zst
coredns-f8a02aaf58f26ae1791092ca37ac469c74c41172.zip
dont panic when from-zone cannot be normalized (#5170)
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
-rw-r--r--plugin/forward/setup.go3
-rw-r--r--plugin/forward/setup_test.go1
2 files changed, 4 insertions, 0 deletions
diff --git a/plugin/forward/setup.go b/plugin/forward/setup.go
index 010dfa754..baf0512ba 100644
--- a/plugin/forward/setup.go
+++ b/plugin/forward/setup.go
@@ -94,6 +94,9 @@ func parseStanza(c *caddy.Controller) (*Forward, error) {
}
origFrom := f.from
zones := plugin.Host(f.from).NormalizeExact()
+ if len(zones) == 0 {
+ return f, fmt.Errorf("unable to normalize '%s'", f.from)
+ }
f.from = zones[0] // there can only be one here, won't work with non-octet reverse
if len(zones) > 1 {
diff --git a/plugin/forward/setup_test.go b/plugin/forward/setup_test.go
index e1a3a74a7..3c38acf97 100644
--- a/plugin/forward/setup_test.go
+++ b/plugin/forward/setup_test.go
@@ -38,6 +38,7 @@ func TestSetup(t *testing.T) {
{`forward . ::1
forward com ::2`, true, "", nil, 0, options{hcRecursionDesired: true}, "plugin"},
{"forward . https://127.0.0.1 \n", true, ".", nil, 2, options{hcRecursionDesired: true}, "'https' is not supported as a destination protocol in forward: https://127.0.0.1"},
+ {"forward xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 127.0.0.1 \n", true, ".", nil, 2, options{hcRecursionDesired: true}, "unable to normalize 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'"},
}
for i, test := range tests {