Skip to content

Commit 4276c19

Browse files
Potential fix for code scanning alert no. 46: Incorrect conversion between integer types
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 265623f commit 4276c19

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

cmd/monitorv2/renderer/tview_renderer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2055,6 +2055,9 @@ func (t *TviewRenderer) calculateBlockInterval(block rpctypes.PolyBlock, index i
20552055
if prevTime > math.MaxInt64 {
20562056
log.Error().Uint64("prev_time", prevTime).Msg("Previous block time exceeds int64 range, clamping to MaxInt64")
20572057
prevTime = math.MaxInt64
2058+
} else if prevTime < 0 {
2059+
log.Error().Uint64("prev_time", prevTime).Msg("Previous block time is negative, clamping to 0")
2060+
prevTime = 0
20582061
}
20592062
// Ensure values are within int64 range before conversion
20602063
clampedBlockTime := int64(blockTime)

rpctypes/rpctypes.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,10 @@ func (r RawQuantityResponse) ToUint64() uint64 {
665665
if err != nil {
666666
return 0
667667
}
668+
if result > math.MaxUint64 {
669+
log.Error().Uint64("value", result).Msg("Value exceeds uint64 range, clamping to MaxUint64")
670+
result = math.MaxUint64
671+
}
668672
return uint64(result)
669673
}
670674
func (r RawQuantityResponse) ToFloat64() float64 {

0 commit comments

Comments
 (0)