1
0
mirror of https://github.com/securego/gosec.git synced 2025-07-17 01:12:33 +02:00

Fix conversion overflow false positive when using ParseUint

This commit is contained in:
Ben Krieger
2024-08-27 13:11:51 -04:00
committed by Cosmin Cojocar
parent c52dc0ea4e
commit 4ae73c8ba3
2 changed files with 37 additions and 2 deletions

View File

@ -356,4 +356,38 @@ func main() {
}
`,
}, 0, gosec.NewConfig()},
{[]string{
`
package main
import (
"fmt"
"strconv"
)
func main() {
var a string = "13"
b, _ := strconv.ParseUint(a, 10, 8)
c := uint8(b)
fmt.Printf("%d\n", c)
}
`,
}, 0, gosec.NewConfig()},
{[]string{
`
package main
import (
"fmt"
"strconv"
)
func main() {
var a string = "13"
b, _ := strconv.ParseInt(a, 10, 8)
c := uint8(b)
fmt.Printf("%d\n", c)
}
`,
}, 1, gosec.NewConfig()},
}