mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 00:34:24 -04:00
plugin/loop: avoid panic on invalid server block (#7568)
Ignore invalid ServerBlockKeys in loop plugin that fail normalization. Retain the default “.” zone instead of indexing into an empty slice. This prevents an index-out-of-range panic triggered by malformed inputs such as "unix://". Added tests to validate and increase test coverage. Signed-off-by: Ville Vesilehto <ville@vesilehto.fi>
This commit is contained in:
@@ -73,7 +73,10 @@ func parse(c *caddy.Controller) (*Loop, error) {
|
||||
}
|
||||
|
||||
if len(c.ServerBlockKeys) > 0 {
|
||||
zones = plugin.Host(c.ServerBlockKeys[0]).NormalizeExact()
|
||||
z := plugin.Host(c.ServerBlockKeys[0]).NormalizeExact()
|
||||
if len(z) > 0 {
|
||||
zones = z
|
||||
}
|
||||
}
|
||||
}
|
||||
return New(zones[0]), nil
|
||||
|
||||
Reference in New Issue
Block a user