diff options
author | 2021-11-20 00:19:25 +0800 | |
---|---|---|
committer | 2021-11-19 16:19:25 +0000 | |
commit | 71bb575b7187852a100f54453c519b8a2c821cb1 (patch) | |
tree | 8ee068fa03a1e2d94a07da0a28e428abc7c1dfb9 /plugin/file/setup.go | |
parent | e799a0f5c7ae90b6db3b9f63e2d82765b30200e6 (diff) | |
download | coredns-71bb575b7187852a100f54453c519b8a2c821cb1.tar.gz coredns-71bb575b7187852a100f54453c519b8a2c821cb1.tar.zst coredns-71bb575b7187852a100f54453c519b8a2c821cb1.zip |
plugin/auto: Fix panic caused by config invalid reload value (#4986)
Automatically submitted.
Diffstat (limited to 'plugin/file/setup.go')
-rw-r--r-- | plugin/file/setup.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/plugin/file/setup.go b/plugin/file/setup.go index 0444836b5..f25fba735 100644 --- a/plugin/file/setup.go +++ b/plugin/file/setup.go @@ -1,6 +1,7 @@ package file import ( + "errors" "os" "path/filepath" "time" @@ -108,7 +109,11 @@ func fileParse(c *caddy.Controller) (Zones, error) { for c.NextBlock() { switch c.Val() { case "reload": - d, err := time.ParseDuration(c.RemainingArgs()[0]) + t := c.RemainingArgs() + if len(t) < 1 { + return Zones{}, errors.New("reload duration value is expected") + } + d, err := time.ParseDuration(t[0]) if err != nil { return Zones{}, plugin.Error("file", err) } |