-
Notifications
You must be signed in to change notification settings - Fork 221
Sf 1.11.0 #7484
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
base: master
Are you sure you want to change the base?
Conversation
# Conflicts: # consensus/spos/bls/constants.go # consensus/spos/consensusMessageValidator.go # go.mod # go.sum # process/block/metablock.go
# Conflicts: # go.mod # go.sum
| roundsPerEpochUint = minRoundModulus | ||
| } | ||
|
|
||
| mp.nrEpochsChanges = int(epochs) |
Check failure
Code scanning / CodeQL
Incorrect conversion between integer types High
strconv.ParseInt
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 month ago
The correct way to fix this is to ensure that the int64 value (epochs) is within the representable range for the type we're converting to (int) before the conversion takes place. This can be done by explicitly checking that epochs is between math.MinInt and math.MaxInt. If the bounds are violated, the application should either reject the input (log an error and do not apply the mutation), or fallback to a default safe value/behavior. To implement this, import the math package if it is not already present (it is), and insert a conditional check before assigning to mp.nrEpochsChanges. This check should act as a guard, such that if epochs is out of bounds, mp.nrEpochsChanges is not updated and a warning or error is logged.
-
Copy modified lines R2824-R2828
| @@ -2821,6 +2821,11 @@ | ||
| roundsPerEpochUint = minRoundModulus | ||
| } | ||
|
|
||
| // Ensure epochs can safely fit into int before assignment | ||
| if epochs < int64(math.MinInt) || epochs > int64(math.MaxInt) { | ||
| log.Error("epochfastforward", "epochs value out of int bounds", epochs) | ||
| return | ||
| } | ||
| mp.nrEpochsChanges = int(epochs) | ||
| mp.roundsModulus = roundsPerEpochUint | ||
|
|
Reasoning behind the pull request
Proposed changes
Testing procedure
Pre-requisites
Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:
featbranch created?featbranch merging, do all satellite projects have a proper tag insidego.mod?