Commit 041e1eab authored by Yong Tang's avatar Yong Tang Committed by GitHub

Fix a couple of code scanning alerts (#5157)

This PR fixed a couple of code scanning alerts:
Signed-off-by: default avatarYong Tang <yong.tang.github@outlook.com>
parent 69473c5c
...@@ -163,13 +163,10 @@ func parseBlock(c *caddy.Controller, f *Forward) error { ...@@ -163,13 +163,10 @@ func parseBlock(c *caddy.Controller, f *Forward) error {
if !c.NextArg() { if !c.NextArg() {
return c.ArgErr() return c.ArgErr()
} }
n, err := strconv.Atoi(c.Val()) n, err := strconv.ParseUint(c.Val(), 10, 32)
if err != nil { if err != nil {
return err return err
} }
if n < 0 {
return fmt.Errorf("max_fails can't be negative: %d", n)
}
f.maxfails = uint32(n) f.maxfails = uint32(n)
case "health_check": case "health_check":
if !c.NextArg() { if !c.NextArg() {
......
...@@ -45,7 +45,7 @@ func (wh Whoami) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) ...@@ -45,7 +45,7 @@ func (wh Whoami) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
if state.QName() == "." { if state.QName() == "." {
srv.Hdr.Name = "_" + state.Proto() + 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.Port = uint16(port)
srv.Target = "." srv.Target = "."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment