Skip to content

Commit

Permalink
Address golangci-lint v1.60.3 errors
Browse files Browse the repository at this point in the history
Specifically, gosec "integer overflow conversion" issues.

Signed-off-by: Tom Pantelis <[email protected]>
  • Loading branch information
tpantelis authored and skitt committed Aug 29, 2024
1 parent 3844280 commit 724832a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ linters:
- bidichk
- bodyclose
- contextcheck
- copyloopvar
# - cyclop # This is equivalent to gocyclo
# - depguard # depguard now denies by default, it should only be enabled if we actually use it
- dogsled
Expand All @@ -53,7 +54,6 @@ linters:
- errname
- exhaustive
# - exhaustivestruct # Not recommended for general use - meant to be used only for special cases
- exportloopref
# - forbidigo # We don't forbid any statements
# - forcetypeassert # There are many unchecked type assertions that would be the result of a programming error so the
# reasonable recourse would be to panic anyway if checked so this doesn't seem useful
Expand Down
2 changes: 1 addition & 1 deletion coredns/plugin/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (lh *Lighthouse) createSRVRecords(dnsrecords []resolver.DNSRecord, state *r
Hdr: dns.RR_Header{Name: state.QName(), Rrtype: dns.TypeSRV, Class: state.QClass(), Ttl: lh.TTL},
Priority: 0,
Weight: 50,
Port: uint16(port.Port),
Port: uint16(port.Port), //nolint:gosec // Need to ignore integer conversion error
Target: target,
}
records = append(records, record)
Expand Down
4 changes: 2 additions & 2 deletions coredns/plugin/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func parseTTL(c *caddy.Controller) (uint32, error) {
return 0, c.ArgErr() //nolint:wrapcheck // No need to wrap this.
}

t, err := strconv.Atoi(args[0])
t, err := strconv.ParseInt(args[0], 10, 32)
if err != nil {
return 0, errors.Wrap(err, "error parsing TTL")
}
Expand All @@ -186,7 +186,7 @@ func parseTTL(c *caddy.Controller) (uint32, error) {
return 0, c.Errf("ttl must be in range [0, 3600]: %d", t) //nolint:wrapcheck // No need to wrap this.
}

return uint32(t), nil
return uint32(t), nil //nolint:gosec // We can safely ignore integer conversion error
}

func init() {
Expand Down

0 comments on commit 724832a

Please sign in to comment.