Skip to content

Commit 773f46d

Browse files
committed
Add failing test for upper bound checks
1 parent 0ed0145 commit 773f46d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

go/ql/test/query-tests/Security/CWE-681/IncorrectIntegerConversion.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,11 @@ func testBoundsChecking(input string) {
333333
_ = uint16(parsed)
334334
_ = int16(parsed) // $ hasValueFlow="type conversion"
335335
}
336-
if parsed < 5 {
337-
_ = uint16(parsed)
336+
if parsed <= 255 {
337+
_ = uint8(parsed)
338+
}
339+
if parsed <= 256 {
340+
_ = uint8(parsed) // $ hasValueFlow="type conversion"
338341
}
339342
if err == nil && 1 == 1 && parsed < math.MaxInt8 {
340343
_ = int8(parsed)

0 commit comments

Comments
 (0)