Description
Summary
G115 reports issues even if we do proper bounds checks. This is similar in spirit to #1185, but would require the linter to be smarter.
Steps to reproduce the behavior
var x []string
if len(x) <= math.MaxUint32 {
y := uint32(len(x))
fmt.Println(y)
}
This reports integer overflow conversion int -> uint32 (gosec)
.
gosec version
I am running via golangci-lint v1.62.0.
Go version (output of 'go version')
n/a
Operating system / Environment
n/a
Expected behavior
The linter should see that there is a bounds check and thus be able to prove to itself that the overflow is impossible.
Actual behavior
The linter does not consider anything about prior bounds checks, leading to false positives that need to be ignored, diminishing the utility of the check.