Closed wsodsong closed 3 months ago
Incoming string range 0-2**64, but converted to int32 eventually.
https://codeql.github.com/codeql-query-help/go/go-incorrect-integer-conversion/
func parseAllocateGood4(wanted string) int32 {
parsed, err := strconv.ParseInt(wanted, 10, 64)
if err != nil {
panic(err)
}
// GOOD: check for lower and uppper bounds
if parsed > 0 && parsed <= math.MaxInt32 {
return int32(parsed)
}
return DefaultAllocate
}
Tracking issue for: