Skip to content

Commit

Permalink
Fix overflow check
Browse files Browse the repository at this point in the history
Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
  • Loading branch information
dbussink committed Jan 29, 2025
1 parent 9e8ba03 commit 829caf0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions go/vt/vtctl/grpcvtctldserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1510,15 +1510,15 @@ func (s *VtctldServer) GetBackups(ctx context.Context, req *vtctldatapb.GetBacku

totalBackups := len(bhs)
if req.Limit > 0 {
if req.Limit > math.MaxInt {
if int(req.Limit) < 0 {
return nil, fmt.Errorf("limit %v exceeds maximum allowed value %v", req.DetailedLimit, math.MaxInt)
}
totalBackups = int(req.Limit)
}

totalDetailedBackups := len(bhs)
if req.DetailedLimit > 0 {
if req.DetailedLimit > math.MaxInt {
if int(req.DetailedLimit) < 0 {
return nil, fmt.Errorf("detailed_limit %v exceeds maximum allowed value %v", req.DetailedLimit, math.MaxInt)
}
totalDetailedBackups = int(req.DetailedLimit)
Expand Down

0 comments on commit 829caf0

Please sign in to comment.