-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add SML document #1
Conversation
if err != nil { | ||
return 0, err | ||
} | ||
p.forward(i) | ||
|
||
return size, nil | ||
return int(size), nil //nolint:gosec |
Check failure
Code scanning / CodeQL
Incorrect conversion between integer types High
strconv.ParseUint
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
To fix the problem, we need to ensure that the value parsed from the string does not exceed the maximum value that an int
can hold. We can achieve this by adding a bounds check after parsing the value with strconv.ParseUint
. If the value exceeds the maximum value for an int
, we should return an error.
-
Copy modified line R7 -
Copy modified lines R838-R840
@@ -6,2 +6,3 @@ | ||
"strconv" | ||
"math" | ||
"strings" | ||
@@ -836,2 +837,5 @@ | ||
} | ||
if size > math.MaxInt32 { | ||
return 0, errors.New("parsed size exceeds maximum int value") | ||
} | ||
p.forward(i) |
No description provided.