Skip to content

Commit 39eeed9

Browse files
committed
Add failing test showcasing problem
1 parent 9652679 commit 39eeed9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,15 @@ func testBoundsChecking(input string) {
349349
}
350350
}
351351

352+
func testBoundsChecking2(input string) error {
353+
version, err := strconv.ParseUint(input, 10, 0)
354+
if err != nil || version > math.MaxInt {
355+
return fmt.Errorf("checksum has invalid version: %w", err)
356+
}
357+
_ = int(version)
358+
return nil
359+
}
360+
352361
func testRightShifted(input string) {
353362
{
354363
parsed, err := strconv.ParseInt(input, 10, 32)

0 commit comments

Comments
 (0)