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:
Ville Vesilehto
2025-09-22 08:44:36 +03:00
committed by GitHub
parent 0d05791404
commit 31e285994b
3 changed files with 105 additions and 2 deletions

View File

@@ -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