From 041e1eabc6022cba5e59a8b99d4226dea2bc4b0a Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Mon, 7 Feb 2022 06:09:12 -0800 Subject: [PATCH] Fix a couple of code scanning alerts (#5157) This PR fixed a couple of code scanning alerts: Signed-off-by: Yong Tang --- plugin/forward/setup.go | 5 +---- plugin/whoami/whoami.go | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/plugin/forward/setup.go b/plugin/forward/setup.go index 1f88daba5..8bd1e1ff4 100644 --- a/plugin/forward/setup.go +++ b/plugin/forward/setup.go @@ -163,13 +163,10 @@ func parseBlock(c *caddy.Controller, f *Forward) error { if !c.NextArg() { return c.ArgErr() } - n, err := strconv.Atoi(c.Val()) + n, err := strconv.ParseUint(c.Val(), 10, 32) if err != nil { return err } - if n < 0 { - return fmt.Errorf("max_fails can't be negative: %d", n) - } f.maxfails = uint32(n) case "health_check": if !c.NextArg() { diff --git a/plugin/whoami/whoami.go b/plugin/whoami/whoami.go index fffc3be37..b46736c91 100644 --- a/plugin/whoami/whoami.go +++ b/plugin/whoami/whoami.go @@ -45,7 +45,7 @@ func (wh Whoami) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) if state.QName() == "." { srv.Hdr.Name = "_" + state.Proto() + state.QName() } - port, _ := strconv.Atoi(state.Port()) + port, _ := strconv.ParseUint(state.Port(), 10, 16) srv.Port = uint16(port) srv.Target = "."